From e5530c0d7e5868a40d94da940d35721890003e60 Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Wed, 25 Oct 2023 13:17:31 +0200 Subject: [PATCH] Fix shipping rate discount factory This factory would violate a not-null constraint. --- .../factories/friendly_shipping_rate_discount_factory.rb | 6 +++++- .../testing_support/factories_spec.rb | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/solidus_friendly_promotions/testing_support/factories/friendly_shipping_rate_discount_factory.rb b/lib/solidus_friendly_promotions/testing_support/factories/friendly_shipping_rate_discount_factory.rb index 27594efc..802fb490 100644 --- a/lib/solidus_friendly_promotions/testing_support/factories/friendly_shipping_rate_discount_factory.rb +++ b/lib/solidus_friendly_promotions/testing_support/factories/friendly_shipping_rate_discount_factory.rb @@ -4,7 +4,11 @@ factory :friendly_shipping_rate_discount, class: "SolidusFriendlyPromotions::ShippingRateDiscount" do amount { BigDecimal("-4.00") } shipping_rate - promotion_action { SolidusFriendlyPromotions::Actions::AdjustShipment.new } + promotion_action do + promotion = create(:friendly_promotion, name: "10% off shipping!", customer_label: "10% off") + ten_percent = SolidusFriendlyPromotions::Calculators::Percent.new(preferred_percent: 10) + SolidusFriendlyPromotions::Actions::AdjustShipment.create!(promotion: promotion, calculator: ten_percent) + end label { "10% off" } end end diff --git a/spec/lib/solidus_friendly_promotions/testing_support/factories_spec.rb b/spec/lib/solidus_friendly_promotions/testing_support/factories_spec.rb index 1e46e37f..bd711049 100644 --- a/spec/lib/solidus_friendly_promotions/testing_support/factories_spec.rb +++ b/spec/lib/solidus_friendly_promotions/testing_support/factories_spec.rb @@ -10,7 +10,8 @@ :friendly_promotion_with_first_order_rule, :friendly_promotion_with_item_adjustment, :friendly_promotion_with_item_total_rule, - :friendly_promotion_with_order_adjustment + :friendly_promotion_with_order_adjustment, + :friendly_shipping_rate_discount ].each do |factory| expect { FactoryBot.create(factory) }.not_to raise_exception end