Skip to content

Commit

Permalink
Merge pull request #5738 from mamhoff/promotions-attribute-accessor
Browse files Browse the repository at this point in the history
Configure promotions via a configuration instance
  • Loading branch information
kennyadsl authored May 3, 2024
2 parents fdc5e1c + 6712bd3 commit 754c58b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions core/lib/spree/app_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -422,12 +422,6 @@ def payment_canceller
)
end

# Allow switching out the promotion configuration class
#
# @!attribute [rw] promotion_configuration_class
# @return [Class] a class instance that fulfils the interface of a promo configuration
class_name_attribute :promotion_configuration_class, default: 'Spree::Core::PromotionConfiguration'

# Allows providing your own class for adding payment sources to a user's
# "wallet" after an order moves to the complete state.
#
Expand Down Expand Up @@ -594,8 +588,13 @@ def stock
@stock_configuration ||= Spree::Core::StockConfiguration.new
end

# Allows providing your own promotion configuration instance
# @!attribute [rw] promotions
# @return [Spree::Core::PromotionConfiguration] an object that conforms to the API of
# the standard promotion configuration class Spree::Core::PromotionConfiguration.
attr_writer :promotions
def promotions
@promotion_configuration ||= promotion_configuration_class.new
@promotions ||= Spree::Core::PromotionConfiguration.new
end

class << self
Expand Down
2 changes: 1 addition & 1 deletion core/spec/lib/spree/app_configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
end

it "uses core's promotion configuration class by default" do
expect(prefs.promotion_configuration_class).to eq Spree::Core::PromotionConfiguration
expect(prefs.promotions).to be_a Spree::Core::PromotionConfiguration
end

context "deprecated preferences" do
Expand Down

0 comments on commit 754c58b

Please sign in to comment.