diff --git a/core/app/models/spree/order.rb b/core/app/models/spree/order.rb index d33a6ab335..eae408eb39 100644 --- a/core/app/models/spree/order.rb +++ b/core/app/models/spree/order.rb @@ -108,8 +108,6 @@ def states foreign_key: :order_id, dependent: :destroy, inverse_of: :order - has_many :order_promotions, class_name: 'Spree::OrderPromotion', dependent: :destroy - has_many :promotions, through: :order_promotions # Payments has_many :payments, dependent: :destroy, inverse_of: :order diff --git a/core/spec/models/spree/order_spec.rb b/core/spec/models/spree/order_spec.rb index f40aa63b40..c669fa98df 100644 --- a/core/spec/models/spree/order_spec.rb +++ b/core/spec/models/spree/order_spec.rb @@ -1806,20 +1806,6 @@ def validate(line_item) end end - describe "order deletion" do - let(:order) { create(:order) } - let(:promotion) { create(:promotion) } - - subject { order.destroy } - before do - order.promotions << promotion - end - - it "deletes join table entries when deleting an order" do - expect { subject }.to change { Spree::OrderPromotion.count }.from(1).to(0) - end - end - describe ".find_by_param" do let(:order) { create(:order) } let(:param) { order.number } diff --git a/legacy_promotions/app/decorators/solidus_legacy_promotions/models/spree/order_decorator.rb b/legacy_promotions/app/decorators/solidus_legacy_promotions/models/spree/order_decorator.rb deleted file mode 100644 index a74d3e4a25..0000000000 --- a/legacy_promotions/app/decorators/solidus_legacy_promotions/models/spree/order_decorator.rb +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true - -module SolidusLegacyPromotions - module OrderDecorator - def apply_shipping_promotions(_event = nil) - ::Spree::Config.promotions.shipping_promotion_handler_class.new(self).activate - recalculate - end - - ::Spree::Order.prepend(self) - end -end diff --git a/legacy_promotions/app/decorators/solidus_legacy_promotions/models/spree_order_decorator.rb b/legacy_promotions/app/decorators/solidus_legacy_promotions/models/spree_order_decorator.rb new file mode 100644 index 0000000000..4ba9536b01 --- /dev/null +++ b/legacy_promotions/app/decorators/solidus_legacy_promotions/models/spree_order_decorator.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module SolidusLegacyPromotions + module SpreeOrderDecorator + def self.prepended(base) + base.has_many :order_promotions, class_name: 'Spree::OrderPromotion', dependent: :destroy + base.has_many :promotions, through: :order_promotions + end + + def apply_shipping_promotions(_event = nil) + Spree::Config.promotions.shipping_promotion_handler_class.new(self).activate + recalculate + end + + Spree::Order.prepend(self) + end +end