From 5bc7e5aab3a7b6e5fb7429cf7d645023a31e18ab Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Mon, 2 Oct 2023 20:05:31 +0200 Subject: [PATCH] Use Spree::{Order;LineItem;ShippingRate} in all models It's less change to all rules and actions if we just use the core Solidus models to store discounts. --- .../actions/adjust_line_item.rb | 2 +- .../actions/adjust_shipment.rb | 2 +- .../friendly_promotion_discounter.rb | 6 +++-- .../order_discounter.rb | 24 +++++++++---------- .../rules/first_order.rb | 2 +- .../rules/first_repeat_purchase_since.rb | 2 +- .../rules/item_total.rb | 2 +- .../rules/line_item_option_value.rb | 2 +- .../rules/line_item_product.rb | 2 +- .../rules/line_item_taxon.rb | 2 +- .../rules/nth_order.rb | 2 +- .../rules/one_use_per_user.rb | 2 +- .../rules/option_value.rb | 2 +- .../rules/product.rb | 2 +- .../rules/shipping_method.rb | 2 +- .../rules/store.rb | 2 +- .../rules/taxon.rb | 2 +- .../solidus_friendly_promotions/rules/user.rb | 2 +- .../rules/user_logged_in.rb | 2 +- .../rules/user_role.rb | 2 +- .../actions/adjust_shipment_spec.rb | 6 ++--- .../calculators/distributed_amount_spec.rb | 3 +-- .../calculators/percent_spec.rb | 2 +- .../calculators/tiered_flat_rate_spec.rb | 5 ++-- .../distributed_amounts_handler_spec.rb | 6 +---- .../promotion_action_spec.rb | 3 +-- .../rules/first_repeat_purchase_since_spec.rb | 4 ++-- .../rules/nth_order_spec.rb | 2 +- .../rules/option_value_spec.rb | 4 ++-- 29 files changed, 48 insertions(+), 53 deletions(-) diff --git a/promotions/app/models/solidus_friendly_promotions/actions/adjust_line_item.rb b/promotions/app/models/solidus_friendly_promotions/actions/adjust_line_item.rb index 0e2bc9ce..394d0b66 100644 --- a/promotions/app/models/solidus_friendly_promotions/actions/adjust_line_item.rb +++ b/promotions/app/models/solidus_friendly_promotions/actions/adjust_line_item.rb @@ -4,7 +4,7 @@ module SolidusFriendlyPromotions module Actions class AdjustLineItem < PromotionAction def can_discount?(object) - object.is_a? Discountable::LineItem + object.is_a? Spree::LineItem end def available_calculators diff --git a/promotions/app/models/solidus_friendly_promotions/actions/adjust_shipment.rb b/promotions/app/models/solidus_friendly_promotions/actions/adjust_shipment.rb index d52354ab..82d73533 100644 --- a/promotions/app/models/solidus_friendly_promotions/actions/adjust_shipment.rb +++ b/promotions/app/models/solidus_friendly_promotions/actions/adjust_shipment.rb @@ -4,7 +4,7 @@ module SolidusFriendlyPromotions module Actions class AdjustShipment < PromotionAction def can_discount?(object) - object.is_a?(Discountable::Shipment) || object.is_a?(Discountable::ShippingRate) + object.is_a?(Spree::Shipment) || object.is_a?(Spree::ShippingRate) end def available_calculators diff --git a/promotions/app/models/solidus_friendly_promotions/friendly_promotion_discounter.rb b/promotions/app/models/solidus_friendly_promotions/friendly_promotion_discounter.rb index e3945e1e..9c1d7b4e 100644 --- a/promotions/app/models/solidus_friendly_promotions/friendly_promotion_discounter.rb +++ b/promotions/app/models/solidus_friendly_promotions/friendly_promotion_discounter.rb @@ -5,13 +5,15 @@ class FriendlyPromotionDiscounter attr_reader :order, :promotions def initialize(order) - @order = Discountable::Order.new(order) + @order = order @promotions = PromotionEligibility.new(promotable: order, possible_promotions: possible_promotions).call end def call return nil if order.shipped? + order.reset_current_discounts + SolidusFriendlyPromotions::Promotion.ordered_lanes.each do |lane, _index| lane_promotions = promotions.select { |promotion| promotion.lane == lane } item_discounter = ItemDiscounter.new(promotions: lane_promotions) @@ -19,7 +21,7 @@ def call shipment_discounts = adjust_shipments(item_discounter) shipping_rate_discounts = adjust_shipping_rates(item_discounter) (line_item_discounts + shipment_discounts + shipping_rate_discounts).each do |item, chosen_discounts| - item.discounts.concat(chosen_discounts) + item.current_discounts.concat(chosen_discounts) end end diff --git a/promotions/app/models/solidus_friendly_promotions/order_discounter.rb b/promotions/app/models/solidus_friendly_promotions/order_discounter.rb index d0cfb204..7792c65a 100644 --- a/promotions/app/models/solidus_friendly_promotions/order_discounter.rb +++ b/promotions/app/models/solidus_friendly_promotions/order_discounter.rb @@ -9,19 +9,18 @@ def initialize(order) def call discountable_order = FriendlyPromotionDiscounter.new(order).call - discountable_order.line_items.each do |discountable_line_item| - update_adjustments(discountable_line_item.line_item, discountable_line_item.discounts) + discountable_order.line_items.each do |line_item| + update_adjustments(line_item, line_item.current_discounts) end - discountable_order.shipments.each do |discountable_shipment| - update_adjustments(discountable_shipment.shipment, discountable_shipment.discounts) + discountable_order.shipments.each do |shipment| + update_adjustments(shipment, shipment.current_discounts) end - discountable_order.shipments.flat_map(&:shipping_rates).each do |discountable_shipping_rate| - spree_shipping_rate = discountable_shipping_rate.shipping_rate - spree_shipping_rate.discounts = discountable_shipping_rate.discounts.map do |discount| + discountable_order.shipments.flat_map(&:shipping_rates).each do |shipping_rate| + shipping_rate.discounts = shipping_rate.current_discounts.map do |discount| SolidusFriendlyPromotions::ShippingRateDiscount.new( - shipping_rate: spree_shipping_rate, + shipping_rate: shipping_rate, amount: discount.amount, label: discount.label ) @@ -42,17 +41,18 @@ def call # # @private # @param [#adjustments] item a {Spree::LineItem} or {Spree::Shipment} - # @param [Array] taxed_items a list of calculated discounts for an item + # @param [Array] item_discounts a list of calculated discounts for an item # @return [void] - def update_adjustments(item, taxed_items) + def update_adjustments(item, item_discounts) promotion_adjustments = item.adjustments.select(&:friendly_promotion?) - active_adjustments = taxed_items.map do |tax_item| - update_adjustment(item, tax_item) + active_adjustments = item_discounts.map do |item_discount| + update_adjustment(item, item_discount) end item.update(promo_total: active_adjustments.sum(&:amount)) # Remove any tax adjustments tied to rates which no longer match. unmatched_adjustments = promotion_adjustments - active_adjustments + item.adjustments.destroy(unmatched_adjustments) end diff --git a/promotions/app/models/solidus_friendly_promotions/rules/first_order.rb b/promotions/app/models/solidus_friendly_promotions/rules/first_order.rb index 9d6f81f9..65ccd992 100644 --- a/promotions/app/models/solidus_friendly_promotions/rules/first_order.rb +++ b/promotions/app/models/solidus_friendly_promotions/rules/first_order.rb @@ -6,7 +6,7 @@ class FirstOrder < PromotionRule attr_reader :user, :email def applicable?(promotable) - promotable.is_a?(Discountable::Order) + promotable.is_a?(Spree::Order) end def eligible?(order, options = {}) diff --git a/promotions/app/models/solidus_friendly_promotions/rules/first_repeat_purchase_since.rb b/promotions/app/models/solidus_friendly_promotions/rules/first_repeat_purchase_since.rb index 2f64e454..dfca9645 100644 --- a/promotions/app/models/solidus_friendly_promotions/rules/first_repeat_purchase_since.rb +++ b/promotions/app/models/solidus_friendly_promotions/rules/first_repeat_purchase_since.rb @@ -8,7 +8,7 @@ class FirstRepeatPurchaseSince < PromotionRule # This promotion is applicable to orders only. def applicable?(promotable) - promotable.is_a?(Discountable::Order) + promotable.is_a?(Spree::Order) end # This is never eligible if the order does not have a user, and that user does not have any previous completed orders. diff --git a/promotions/app/models/solidus_friendly_promotions/rules/item_total.rb b/promotions/app/models/solidus_friendly_promotions/rules/item_total.rb index 55fc42ec..12df8523 100644 --- a/promotions/app/models/solidus_friendly_promotions/rules/item_total.rb +++ b/promotions/app/models/solidus_friendly_promotions/rules/item_total.rb @@ -27,7 +27,7 @@ def self.operator_options end def applicable?(promotable) - promotable.is_a?(Discountable::Order) + promotable.is_a?(Spree::Order) end def eligible?(order, _options = {}) diff --git a/promotions/app/models/solidus_friendly_promotions/rules/line_item_option_value.rb b/promotions/app/models/solidus_friendly_promotions/rules/line_item_option_value.rb index a914702a..b8252820 100644 --- a/promotions/app/models/solidus_friendly_promotions/rules/line_item_option_value.rb +++ b/promotions/app/models/solidus_friendly_promotions/rules/line_item_option_value.rb @@ -6,7 +6,7 @@ class LineItemOptionValue < PromotionRule preference :eligible_values, :hash def applicable?(promotable) - promotable.is_a?(Discountable::LineItem) + promotable.is_a?(Spree::LineItem) end def eligible?(line_item, _options = {}) diff --git a/promotions/app/models/solidus_friendly_promotions/rules/line_item_product.rb b/promotions/app/models/solidus_friendly_promotions/rules/line_item_product.rb index fb16c2fd..b24e8e55 100644 --- a/promotions/app/models/solidus_friendly_promotions/rules/line_item_product.rb +++ b/promotions/app/models/solidus_friendly_promotions/rules/line_item_product.rb @@ -17,7 +17,7 @@ class LineItemProduct < PromotionRule preference :match_policy, :string, default: MATCH_POLICIES.first def applicable?(promotable) - promotable.is_a?(Discountable::LineItem) + promotable.is_a?(Spree::LineItem) end def eligible?(line_item, _options = {}) diff --git a/promotions/app/models/solidus_friendly_promotions/rules/line_item_taxon.rb b/promotions/app/models/solidus_friendly_promotions/rules/line_item_taxon.rb index 204a12e2..e0fd27b6 100644 --- a/promotions/app/models/solidus_friendly_promotions/rules/line_item_taxon.rb +++ b/promotions/app/models/solidus_friendly_promotions/rules/line_item_taxon.rb @@ -13,7 +13,7 @@ class LineItemTaxon < PromotionRule preference :match_policy, :string, default: MATCH_POLICIES.first def applicable?(promotable) - promotable.is_a?(Discountable::LineItem) + promotable.is_a?(Spree::LineItem) end def eligible?(line_item, _options = {}) diff --git a/promotions/app/models/solidus_friendly_promotions/rules/nth_order.rb b/promotions/app/models/solidus_friendly_promotions/rules/nth_order.rb index 041cbc53..04cb592b 100644 --- a/promotions/app/models/solidus_friendly_promotions/rules/nth_order.rb +++ b/promotions/app/models/solidus_friendly_promotions/rules/nth_order.rb @@ -10,7 +10,7 @@ class NthOrder < PromotionRule # This promotion is applicable to orders only. def applicable?(promotable) - promotable.is_a?(Discountable::Order) + promotable.is_a?(Spree::Order) end # This is never eligible if the order does not have a user, and that user does not have any previous completed orders. diff --git a/promotions/app/models/solidus_friendly_promotions/rules/one_use_per_user.rb b/promotions/app/models/solidus_friendly_promotions/rules/one_use_per_user.rb index 8393c1ff..5c9d13a8 100644 --- a/promotions/app/models/solidus_friendly_promotions/rules/one_use_per_user.rb +++ b/promotions/app/models/solidus_friendly_promotions/rules/one_use_per_user.rb @@ -4,7 +4,7 @@ module SolidusFriendlyPromotions module Rules class OneUsePerUser < PromotionRule def applicable?(promotable) - promotable.is_a?(Discountable::Order) + promotable.is_a?(Spree::Order) end def eligible?(order, _options = {}) diff --git a/promotions/app/models/solidus_friendly_promotions/rules/option_value.rb b/promotions/app/models/solidus_friendly_promotions/rules/option_value.rb index 9cd76948..f8b25aa0 100644 --- a/promotions/app/models/solidus_friendly_promotions/rules/option_value.rb +++ b/promotions/app/models/solidus_friendly_promotions/rules/option_value.rb @@ -6,7 +6,7 @@ class OptionValue < PromotionRule preference :eligible_values, :hash def applicable?(promotable) - promotable.is_a?(Discountable::Order) + promotable.is_a?(Spree::Order) end def eligible?(order, _options = {}) diff --git a/promotions/app/models/solidus_friendly_promotions/rules/product.rb b/promotions/app/models/solidus_friendly_promotions/rules/product.rb index 02fadb69..c7a5d837 100644 --- a/promotions/app/models/solidus_friendly_promotions/rules/product.rb +++ b/promotions/app/models/solidus_friendly_promotions/rules/product.rb @@ -29,7 +29,7 @@ def eligible_products end def applicable?(promotable) - promotable.is_a?(Discountable::Order) + promotable.is_a?(Spree::Order) end def eligible?(order, _options = {}) diff --git a/promotions/app/models/solidus_friendly_promotions/rules/shipping_method.rb b/promotions/app/models/solidus_friendly_promotions/rules/shipping_method.rb index dce6d5af..eb745f76 100644 --- a/promotions/app/models/solidus_friendly_promotions/rules/shipping_method.rb +++ b/promotions/app/models/solidus_friendly_promotions/rules/shipping_method.rb @@ -6,7 +6,7 @@ class ShippingMethod < PromotionRule preference :shipping_method_ids, type: :array, default: [] def applicable?(promotable) - promotable.is_a?(Discountable::Shipment) || promotable.is_a?(Discountable::ShippingRate) + promotable.is_a?(Spree::Shipment) || promotable.is_a?(Spree::ShippingRate) end def eligible?(promotable) diff --git a/promotions/app/models/solidus_friendly_promotions/rules/store.rb b/promotions/app/models/solidus_friendly_promotions/rules/store.rb index 182e9f49..3c087849 100644 --- a/promotions/app/models/solidus_friendly_promotions/rules/store.rb +++ b/promotions/app/models/solidus_friendly_promotions/rules/store.rb @@ -13,7 +13,7 @@ def preload_relations end def applicable?(promotable) - promotable.is_a?(Discountable::Order) + promotable.is_a?(Spree::Order) end def eligible?(order, _options = {}) diff --git a/promotions/app/models/solidus_friendly_promotions/rules/taxon.rb b/promotions/app/models/solidus_friendly_promotions/rules/taxon.rb index 9f20c285..9130cadc 100644 --- a/promotions/app/models/solidus_friendly_promotions/rules/taxon.rb +++ b/promotions/app/models/solidus_friendly_promotions/rules/taxon.rb @@ -17,7 +17,7 @@ def preload_relations preference :match_policy, :string, default: MATCH_POLICIES.first def applicable?(promotable) - promotable.is_a?(Discountable::Order) + promotable.is_a?(Spree::Order) end def eligible?(order, _options = {}) diff --git a/promotions/app/models/solidus_friendly_promotions/rules/user.rb b/promotions/app/models/solidus_friendly_promotions/rules/user.rb index 7c5a170f..1cb7e9fd 100644 --- a/promotions/app/models/solidus_friendly_promotions/rules/user.rb +++ b/promotions/app/models/solidus_friendly_promotions/rules/user.rb @@ -14,7 +14,7 @@ def preload_relations end def applicable?(promotable) - promotable.is_a?(Discountable::Order) + promotable.is_a?(Spree::Order) end def eligible?(order, _options = {}) diff --git a/promotions/app/models/solidus_friendly_promotions/rules/user_logged_in.rb b/promotions/app/models/solidus_friendly_promotions/rules/user_logged_in.rb index a866884b..5be6e2ea 100644 --- a/promotions/app/models/solidus_friendly_promotions/rules/user_logged_in.rb +++ b/promotions/app/models/solidus_friendly_promotions/rules/user_logged_in.rb @@ -4,7 +4,7 @@ module SolidusFriendlyPromotions module Rules class UserLoggedIn < PromotionRule def applicable?(promotable) - promotable.is_a?(Discountable::Order) + promotable.is_a?(Spree::Order) end def eligible?(order, _options = {}) diff --git a/promotions/app/models/solidus_friendly_promotions/rules/user_role.rb b/promotions/app/models/solidus_friendly_promotions/rules/user_role.rb index 08354c58..e8df12f7 100644 --- a/promotions/app/models/solidus_friendly_promotions/rules/user_role.rb +++ b/promotions/app/models/solidus_friendly_promotions/rules/user_role.rb @@ -9,7 +9,7 @@ class UserRole < PromotionRule preference :match_policy, default: MATCH_POLICIES.first def applicable?(promotable) - promotable.is_a?(Discountable::Order) + promotable.is_a?(Spree::Order) end def eligible?(order, _options = {}) diff --git a/promotions/spec/models/solidus_friendly_promotions/actions/adjust_shipment_spec.rb b/promotions/spec/models/solidus_friendly_promotions/actions/adjust_shipment_spec.rb index 887349b3..eb1709de 100644 --- a/promotions/spec/models/solidus_friendly_promotions/actions/adjust_shipment_spec.rb +++ b/promotions/spec/models/solidus_friendly_promotions/actions/adjust_shipment_spec.rb @@ -15,19 +15,19 @@ subject { action.can_discount?(promotable) } context "with a line item" do - let(:promotable) { SolidusFriendlyPromotions::Discountable::LineItem.new(Spree::Order.new, order: double) } + let(:promotable) { Spree::Order.new } it { is_expected.to be false } end context "with a shipment" do - let(:promotable) { SolidusFriendlyPromotions::Discountable::Shipment.new(Spree::Shipment.new, order: double) } + let(:promotable) { Spree::Shipment.new } it { is_expected.to be true } end context "with a shipping rate" do - let(:promotable) { SolidusFriendlyPromotions::Discountable::ShippingRate.new(Spree::ShippingRate.new, shipment: double) } + let(:promotable) { Spree::ShippingRate.new } it { is_expected.to be true } end diff --git a/promotions/spec/models/solidus_friendly_promotions/calculators/distributed_amount_spec.rb b/promotions/spec/models/solidus_friendly_promotions/calculators/distributed_amount_spec.rb index 1f4cc920..65aca311 100644 --- a/promotions/spec/models/solidus_friendly_promotions/calculators/distributed_amount_spec.rb +++ b/promotions/spec/models/solidus_friendly_promotions/calculators/distributed_amount_spec.rb @@ -10,8 +10,7 @@ end let(:rules) { [] } let(:action) { SolidusFriendlyPromotions::Actions::AdjustLineItem.create(calculator: calculator) } - let(:spree_order) { create(:order_with_line_items, line_items_attributes: line_items_attributes) } - let(:order) { SolidusFriendlyPromotions::Discountable::Order.new(spree_order) } + let(:order) { create(:order_with_line_items, line_items_attributes: line_items_attributes) } let(:currency) { "USD" } context "applied to an order" do diff --git a/promotions/spec/models/solidus_friendly_promotions/calculators/percent_spec.rb b/promotions/spec/models/solidus_friendly_promotions/calculators/percent_spec.rb index fe98125d..025c3578 100644 --- a/promotions/spec/models/solidus_friendly_promotions/calculators/percent_spec.rb +++ b/promotions/spec/models/solidus_friendly_promotions/calculators/percent_spec.rb @@ -7,7 +7,7 @@ context "compute" do let(:currency) { "USD" } let(:order) { double(currency: currency) } - let(:line_item) { double("SolidusFriendlyPromotions::Discountable::LineItem", discountable_amount: 100, order: order) } + let(:line_item) { double("Spree::LineItem", discountable_amount: 100, order: order) } before { subject.preferred_percent = 15 } diff --git a/promotions/spec/models/solidus_friendly_promotions/calculators/tiered_flat_rate_spec.rb b/promotions/spec/models/solidus_friendly_promotions/calculators/tiered_flat_rate_spec.rb index 490dac04..ee438e6c 100644 --- a/promotions/spec/models/solidus_friendly_promotions/calculators/tiered_flat_rate_spec.rb +++ b/promotions/spec/models/solidus_friendly_promotions/calculators/tiered_flat_rate_spec.rb @@ -75,7 +75,7 @@ line_items_price: amount ) end - let(:line_item) { SolidusFriendlyPromotions::Discountable::LineItem.new(order.line_items.first, order: order) } + let(:line_item) { order.line_items.first } let(:preferred_currency) { "USD" } before do @@ -109,8 +109,7 @@ context "with a shipment" do subject { calculator.compute(shipment) } - let(:spree_shipment) { Spree::Shipment.new(order: order, amount: shipping_cost) } - let(:shipment) { SolidusFriendlyPromotions::Discountable::Shipment.new(spree_shipment, order: order) } + let(:shipment) { Spree::Shipment.new(order: order, amount: shipping_cost) } let(:line_item_count) { 1 } let(:amount) { 10 } diff --git a/promotions/spec/models/solidus_friendly_promotions/distributed_amounts_handler_spec.rb b/promotions/spec/models/solidus_friendly_promotions/distributed_amounts_handler_spec.rb index ee267f90..f3d24490 100644 --- a/promotions/spec/models/solidus_friendly_promotions/distributed_amounts_handler_spec.rb +++ b/promotions/spec/models/solidus_friendly_promotions/distributed_amounts_handler_spec.rb @@ -3,17 +3,13 @@ require "spec_helper" RSpec.describe SolidusFriendlyPromotions::DistributedAmountsHandler, type: :model do - let(:spree_order) do + let(:order) do FactoryBot.create( :order_with_line_items, line_items_attributes: line_items_attributes ) end - let(:order) do - SolidusFriendlyPromotions::Discountable::Order.new(spree_order) - end - let(:handler) { described_class.new(order.line_items, total_amount) } diff --git a/promotions/spec/models/solidus_friendly_promotions/promotion_action_spec.rb b/promotions/spec/models/solidus_friendly_promotions/promotion_action_spec.rb index 940f8060..64f039db 100644 --- a/promotions/spec/models/solidus_friendly_promotions/promotion_action_spec.rb +++ b/promotions/spec/models/solidus_friendly_promotions/promotion_action_spec.rb @@ -22,8 +22,7 @@ let(:variant) { create(:variant) } let(:order) { create(:order) } - let(:discountable) { SolidusFriendlyPromotions::Discountable::LineItem.new(line_item, order: SolidusFriendlyPromotions::Discountable::Order.new(order)) } - let(:line_item) { Spree::LineItem.new(order: order, variant: variant, price: 10) } + let(:discountable) { Spree::LineItem.new(order: order, variant: variant, price: 10) } let(:promotion) { SolidusFriendlyPromotions::Promotion.new(name: "20 Perzent off") } let(:action) { described_class.new(promotion: promotion) } diff --git a/promotions/spec/models/solidus_friendly_promotions/rules/first_repeat_purchase_since_spec.rb b/promotions/spec/models/solidus_friendly_promotions/rules/first_repeat_purchase_since_spec.rb index 8edd838e..e23fd17e 100644 --- a/promotions/spec/models/solidus_friendly_promotions/rules/first_repeat_purchase_since_spec.rb +++ b/promotions/spec/models/solidus_friendly_promotions/rules/first_repeat_purchase_since_spec.rb @@ -7,13 +7,13 @@ subject { described_class.new.applicable?(promotable) } context "when the promotable is an order" do - let(:promotable) { SolidusFriendlyPromotions::Discountable::Order.new(Spree::Order.new) } + let(:promotable) { Spree::Order.new } it { is_expected.to be true } end context "when the promotable is not a order" do - let(:promotable) { SolidusFriendlyPromotions::Discountable::LineItem.new(Spree::LineItem.new, order: double) } + let(:promotable) { Spree::LineItem.new } it { is_expected.to be false } end diff --git a/promotions/spec/models/solidus_friendly_promotions/rules/nth_order_spec.rb b/promotions/spec/models/solidus_friendly_promotions/rules/nth_order_spec.rb index a85d4fec..d2464d35 100644 --- a/promotions/spec/models/solidus_friendly_promotions/rules/nth_order_spec.rb +++ b/promotions/spec/models/solidus_friendly_promotions/rules/nth_order_spec.rb @@ -7,7 +7,7 @@ subject { described_class.new.applicable?(promotable) } context "when the promotable is an order" do - let(:promotable) { SolidusFriendlyPromotions::Discountable::Order.new(Spree::Order.new) } + let(:promotable) { Spree::Order.new } it { is_expected.to be true } end diff --git a/promotions/spec/models/solidus_friendly_promotions/rules/option_value_spec.rb b/promotions/spec/models/solidus_friendly_promotions/rules/option_value_spec.rb index 4e29b4c1..51930937 100644 --- a/promotions/spec/models/solidus_friendly_promotions/rules/option_value_spec.rb +++ b/promotions/spec/models/solidus_friendly_promotions/rules/option_value_spec.rb @@ -18,13 +18,13 @@ subject { rule.applicable?(promotable) } context "when promotable is an order" do - let(:promotable) { SolidusFriendlyPromotions::Discountable::Order.new(Spree::Order.new) } + let(:promotable) { Spree::Order.new } it { is_expected.to be true } end context "when promotable is not an order" do - let(:promotable) { SolidusFriendlyPromotions::Discountable::LineItem.new(Spree::LineItem.new, order: double) } + let(:promotable) { Spree::LineItem.new } it { is_expected.to be false } end