diff --git a/core/app/models/spree/promotion.rb b/core/app/models/spree/promotion.rb index 6b4794b7a88..999e79b0db6 100644 --- a/core/app/models/spree/promotion.rb +++ b/core/app/models/spree/promotion.rb @@ -2,7 +2,8 @@ module Spree class Promotion < Spree::Base - MATCH_POLICIES = %w(all any) + + autoload(:MATCH_POLICIES, "spree/promotion/match_policies") UNACTIVATABLE_ORDER_STATES = ["complete", "awaiting_return", "returned"] diff --git a/core/lib/spree/promotion/match_policies.rb b/core/lib/spree/promotion/match_policies.rb new file mode 100644 index 00000000000..712dbd029c9 --- /dev/null +++ b/core/lib/spree/promotion/match_policies.rb @@ -0,0 +1,2 @@ +Spree::Promotion::MATCH_POLICIES = %w(all any) +Spree::Deprecation.warn('Spree::Promotion::MATCH_POLICIES is deprecated') diff --git a/core/spec/models/spree/promotion_spec.rb b/core/spec/models/spree/promotion_spec.rb index 1dcdc483cae..ff848a65299 100644 --- a/core/spec/models/spree/promotion_spec.rb +++ b/core/spec/models/spree/promotion_spec.rb @@ -993,4 +993,11 @@ expect(order.adjustment_total).to eq(-10) end end + + describe "MATCH_POLICIES" do + it "prints a deprecation warning when used" do + expect(Spree::Deprecation).to receive(:warn).once.with(/Spree::Promotion::MATCH_POLICIES is deprecated/) + expect(Spree::Promotion::MATCH_POLICIES).to eq %w(all any) + end + end end