Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename Spree::Config.promotions.promotion_adjuster_class #5752

Merged
merged 1 commit into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/app/models/spree/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ def ensure_inventory_units
end

def ensure_promotions_eligible
Spree::Config.promotions.promotion_adjuster_class.new(self).call
Spree::Config.promotions.order_adjuster_class.new(self).call

if promo_total_changed?
restart_checkout_flow
Expand Down
2 changes: 1 addition & 1 deletion core/app/models/spree/order_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def log_state_change(name)
end

def update_promotions
Spree::Config.promotions.promotion_adjuster_class.new(order).call
Spree::Config.promotions.order_adjuster_class.new(order).call
end

def update_taxes
Expand Down
16 changes: 11 additions & 5 deletions core/lib/spree/app_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -600,15 +600,21 @@
class << self
private

def promotions_deprecation_message(method)
def promotions_deprecation_message(method, new_method_name = nil)
"The `Spree::Config.#{method}` preference is deprecated and will be removed in Solidus 5.0. " \
"Use `Spree::Config.promotions.#{method}` instead"
"Use `Spree::Config.promotions.#{new_method_name || method}` instead"
end
end

delegate :promotion_adjuster_class, :promotion_adjuster_class=, to: :promotions
deprecate promotion_adjuster_class: promotions_deprecation_message("promotion_adjuster_class"), deprecator: Spree.deprecator
deprecate "promotion_adjuster_class=": promotions_deprecation_message("promotion_adjuster_class="), deprecator: Spree.deprecator
def promotion_adjuster_class
promotions.order_adjuster_class
end

def promotion_adjuster_class=(klass)
promotions.order_adjuster_class = klass

Check warning on line 614 in core/lib/spree/app_configuration.rb

View check run for this annotation

Codecov / codecov/patch

core/lib/spree/app_configuration.rb#L614

Added line #L614 was not covered by tests
end
deprecate promotion_adjuster_class: promotions_deprecation_message("promotion_adjuster_class", "order_adjuster_class"), deprecator: Spree.deprecator
deprecate "promotion_adjuster_class=": promotions_deprecation_message("promotion_adjuster_class=", "order_adjuster_class="), deprecator: Spree.deprecator

delegate :promotion_chooser_class, :promotion_chooser_class=, to: :promotions
deprecate promotion_chooser_class: promotions_deprecation_message("promotion_chooser_class"), deprecator: Spree.deprecator
Expand Down
4 changes: 2 additions & 2 deletions core/lib/spree/core/null_promotion_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
module Spree
module Core
class NullPromotionConfiguration < Spree::Preferences::Configuration
# promotion_adjuster_class allows extensions to provide their own Promotion Adjuster
class_name_attribute :promotion_adjuster_class, default: 'Spree::NullPromotionAdjuster'
# order_adjuster_class allows extensions to provide their own Order Adjuster
class_name_attribute :order_adjuster_class, default: 'Spree::NullPromotionAdjuster'

# Allows providing a different coupon code handler.
# @!attribute [rw] coupon_code_handler_class
Expand Down
4 changes: 2 additions & 2 deletions core/lib/spree/core/promotion_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class PromotionConfiguration < Spree::Preferences::Configuration
# promotion_chooser_class allows extensions to provide their own PromotionChooser
class_name_attribute :promotion_chooser_class, default: 'Spree::PromotionChooser'

# promotion_adjuster_class allows extensions to provide their own Promotion Adjuster
class_name_attribute :promotion_adjuster_class, default: 'Spree::Promotion::OrderAdjustmentsRecalculator'
# order_adjuster_class allows extensions to provide their own Order Adjuster
class_name_attribute :order_adjuster_class, default: 'Spree::Promotion::OrderAdjustmentsRecalculator'

# promotion_finder_class allows extensions to provide their own Promotion Finder
class_name_attribute :promotion_finder_class, default: 'Spree::PromotionFinder'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
subject(:config) { described_class.new }

it "uses the null promotion adjuster class by default" do
expect(config.promotion_adjuster_class).to eq Spree::NullPromotionAdjuster
expect(config.order_adjuster_class).to eq Spree::NullPromotionAdjuster
end

it "uses the null coupon code handler class by default" do
Expand Down
2 changes: 1 addition & 1 deletion core/spec/lib/spree/core/promotion_configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
end

it "uses order adjustments recalculator class by default" do
expect(config.promotion_adjuster_class).to eq Spree::Promotion::OrderAdjustmentsRecalculator
expect(config.order_adjuster_class).to eq Spree::Promotion::OrderAdjustmentsRecalculator
end

it "uses promotion handler coupon class by default" do
Expand Down
Loading