diff --git a/friendly_promotions/app/models/solidus_friendly_promotions/actions/adjust_line_item.rb b/friendly_promotions/app/models/solidus_friendly_promotions/actions/adjust_line_item.rb index 0e2bc9ce9ba..394d0b660cd 100644 --- a/friendly_promotions/app/models/solidus_friendly_promotions/actions/adjust_line_item.rb +++ b/friendly_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/friendly_promotions/app/models/solidus_friendly_promotions/actions/adjust_shipment.rb b/friendly_promotions/app/models/solidus_friendly_promotions/actions/adjust_shipment.rb index d52354ab0d2..82d73533943 100644 --- a/friendly_promotions/app/models/solidus_friendly_promotions/actions/adjust_shipment.rb +++ b/friendly_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/friendly_promotions/app/models/solidus_friendly_promotions/friendly_promotion_discounter.rb b/friendly_promotions/app/models/solidus_friendly_promotions/friendly_promotion_discounter.rb index e3945e1eefc..9c1d7b4e978 100644 --- a/friendly_promotions/app/models/solidus_friendly_promotions/friendly_promotion_discounter.rb +++ b/friendly_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/friendly_promotions/app/models/solidus_friendly_promotions/order_discounter.rb b/friendly_promotions/app/models/solidus_friendly_promotions/order_discounter.rb index d0cfb2046cc..7792c65afed 100644 --- a/friendly_promotions/app/models/solidus_friendly_promotions/order_discounter.rb +++ b/friendly_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/friendly_promotions/app/models/solidus_friendly_promotions/rules/first_order.rb b/friendly_promotions/app/models/solidus_friendly_promotions/rules/first_order.rb index 9d6f81f9e99..65ccd9921de 100644 --- a/friendly_promotions/app/models/solidus_friendly_promotions/rules/first_order.rb +++ b/friendly_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/friendly_promotions/app/models/solidus_friendly_promotions/rules/first_repeat_purchase_since.rb b/friendly_promotions/app/models/solidus_friendly_promotions/rules/first_repeat_purchase_since.rb index 2f64e45448a..dfca964597d 100644 --- a/friendly_promotions/app/models/solidus_friendly_promotions/rules/first_repeat_purchase_since.rb +++ b/friendly_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/friendly_promotions/app/models/solidus_friendly_promotions/rules/item_total.rb b/friendly_promotions/app/models/solidus_friendly_promotions/rules/item_total.rb index 55fc42ec782..12df85239e9 100644 --- a/friendly_promotions/app/models/solidus_friendly_promotions/rules/item_total.rb +++ b/friendly_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/friendly_promotions/app/models/solidus_friendly_promotions/rules/line_item_option_value.rb b/friendly_promotions/app/models/solidus_friendly_promotions/rules/line_item_option_value.rb index a914702a4d9..b8252820c6e 100644 --- a/friendly_promotions/app/models/solidus_friendly_promotions/rules/line_item_option_value.rb +++ b/friendly_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/friendly_promotions/app/models/solidus_friendly_promotions/rules/line_item_product.rb b/friendly_promotions/app/models/solidus_friendly_promotions/rules/line_item_product.rb index fb16c2fd645..b24e8e55a38 100644 --- a/friendly_promotions/app/models/solidus_friendly_promotions/rules/line_item_product.rb +++ b/friendly_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/friendly_promotions/app/models/solidus_friendly_promotions/rules/line_item_taxon.rb b/friendly_promotions/app/models/solidus_friendly_promotions/rules/line_item_taxon.rb index 204a12e220c..e0fd27b693f 100644 --- a/friendly_promotions/app/models/solidus_friendly_promotions/rules/line_item_taxon.rb +++ b/friendly_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/friendly_promotions/app/models/solidus_friendly_promotions/rules/nth_order.rb b/friendly_promotions/app/models/solidus_friendly_promotions/rules/nth_order.rb index 041cbc538ba..04cb592bd6c 100644 --- a/friendly_promotions/app/models/solidus_friendly_promotions/rules/nth_order.rb +++ b/friendly_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/friendly_promotions/app/models/solidus_friendly_promotions/rules/one_use_per_user.rb b/friendly_promotions/app/models/solidus_friendly_promotions/rules/one_use_per_user.rb index 8393c1ffddf..5c9d13a89ef 100644 --- a/friendly_promotions/app/models/solidus_friendly_promotions/rules/one_use_per_user.rb +++ b/friendly_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/friendly_promotions/app/models/solidus_friendly_promotions/rules/option_value.rb b/friendly_promotions/app/models/solidus_friendly_promotions/rules/option_value.rb index 9cd76948052..f8b25aa040e 100644 --- a/friendly_promotions/app/models/solidus_friendly_promotions/rules/option_value.rb +++ b/friendly_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/friendly_promotions/app/models/solidus_friendly_promotions/rules/product.rb b/friendly_promotions/app/models/solidus_friendly_promotions/rules/product.rb index 02fadb6945d..c7a5d83732e 100644 --- a/friendly_promotions/app/models/solidus_friendly_promotions/rules/product.rb +++ b/friendly_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/friendly_promotions/app/models/solidus_friendly_promotions/rules/shipping_method.rb b/friendly_promotions/app/models/solidus_friendly_promotions/rules/shipping_method.rb index dce6d5afad8..eb745f7605e 100644 --- a/friendly_promotions/app/models/solidus_friendly_promotions/rules/shipping_method.rb +++ b/friendly_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/friendly_promotions/app/models/solidus_friendly_promotions/rules/store.rb b/friendly_promotions/app/models/solidus_friendly_promotions/rules/store.rb index 182e9f4928c..3c08784975c 100644 --- a/friendly_promotions/app/models/solidus_friendly_promotions/rules/store.rb +++ b/friendly_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/friendly_promotions/app/models/solidus_friendly_promotions/rules/taxon.rb b/friendly_promotions/app/models/solidus_friendly_promotions/rules/taxon.rb index 9f20c285791..9130cadcfe2 100644 --- a/friendly_promotions/app/models/solidus_friendly_promotions/rules/taxon.rb +++ b/friendly_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/friendly_promotions/app/models/solidus_friendly_promotions/rules/user.rb b/friendly_promotions/app/models/solidus_friendly_promotions/rules/user.rb index 7c5a170f88c..1cb7e9fd9da 100644 --- a/friendly_promotions/app/models/solidus_friendly_promotions/rules/user.rb +++ b/friendly_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/friendly_promotions/app/models/solidus_friendly_promotions/rules/user_logged_in.rb b/friendly_promotions/app/models/solidus_friendly_promotions/rules/user_logged_in.rb index a866884b841..5be6e2ea802 100644 --- a/friendly_promotions/app/models/solidus_friendly_promotions/rules/user_logged_in.rb +++ b/friendly_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/friendly_promotions/app/models/solidus_friendly_promotions/rules/user_role.rb b/friendly_promotions/app/models/solidus_friendly_promotions/rules/user_role.rb index 08354c58daf..e8df12f71ba 100644 --- a/friendly_promotions/app/models/solidus_friendly_promotions/rules/user_role.rb +++ b/friendly_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/friendly_promotions/spec/models/solidus_friendly_promotions/actions/adjust_shipment_spec.rb b/friendly_promotions/spec/models/solidus_friendly_promotions/actions/adjust_shipment_spec.rb index 887349b32f1..eb1709dea0b 100644 --- a/friendly_promotions/spec/models/solidus_friendly_promotions/actions/adjust_shipment_spec.rb +++ b/friendly_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/friendly_promotions/spec/models/solidus_friendly_promotions/calculators/distributed_amount_spec.rb b/friendly_promotions/spec/models/solidus_friendly_promotions/calculators/distributed_amount_spec.rb index 1f4cc9200b0..65aca311d33 100644 --- a/friendly_promotions/spec/models/solidus_friendly_promotions/calculators/distributed_amount_spec.rb +++ b/friendly_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/friendly_promotions/spec/models/solidus_friendly_promotions/calculators/percent_spec.rb b/friendly_promotions/spec/models/solidus_friendly_promotions/calculators/percent_spec.rb index fe98125d7dc..025c3578a65 100644 --- a/friendly_promotions/spec/models/solidus_friendly_promotions/calculators/percent_spec.rb +++ b/friendly_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/friendly_promotions/spec/models/solidus_friendly_promotions/calculators/tiered_flat_rate_spec.rb b/friendly_promotions/spec/models/solidus_friendly_promotions/calculators/tiered_flat_rate_spec.rb index 490dac04247..ee438e6c34c 100644 --- a/friendly_promotions/spec/models/solidus_friendly_promotions/calculators/tiered_flat_rate_spec.rb +++ b/friendly_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/friendly_promotions/spec/models/solidus_friendly_promotions/distributed_amounts_handler_spec.rb b/friendly_promotions/spec/models/solidus_friendly_promotions/distributed_amounts_handler_spec.rb index ee267f901c6..f3d244902c0 100644 --- a/friendly_promotions/spec/models/solidus_friendly_promotions/distributed_amounts_handler_spec.rb +++ b/friendly_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/friendly_promotions/spec/models/solidus_friendly_promotions/promotion_action_spec.rb b/friendly_promotions/spec/models/solidus_friendly_promotions/promotion_action_spec.rb index 940f806027a..64f039db186 100644 --- a/friendly_promotions/spec/models/solidus_friendly_promotions/promotion_action_spec.rb +++ b/friendly_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/friendly_promotions/spec/models/solidus_friendly_promotions/rules/first_repeat_purchase_since_spec.rb b/friendly_promotions/spec/models/solidus_friendly_promotions/rules/first_repeat_purchase_since_spec.rb index 8edd838e559..e23fd17e3a3 100644 --- a/friendly_promotions/spec/models/solidus_friendly_promotions/rules/first_repeat_purchase_since_spec.rb +++ b/friendly_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/friendly_promotions/spec/models/solidus_friendly_promotions/rules/nth_order_spec.rb b/friendly_promotions/spec/models/solidus_friendly_promotions/rules/nth_order_spec.rb index a85d4feccc1..d2464d35286 100644 --- a/friendly_promotions/spec/models/solidus_friendly_promotions/rules/nth_order_spec.rb +++ b/friendly_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/friendly_promotions/spec/models/solidus_friendly_promotions/rules/option_value_spec.rb b/friendly_promotions/spec/models/solidus_friendly_promotions/rules/option_value_spec.rb index 4e29b4c16ce..519309378d5 100644 --- a/friendly_promotions/spec/models/solidus_friendly_promotions/rules/option_value_spec.rb +++ b/friendly_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