Skip to content

Commit

Permalink
Use call in the adjustments recalculator's interface
Browse files Browse the repository at this point in the history
We introduced an extension point for promotion adjustments in solidusio#4460 [1].

We change the expected interface from `#adjust!` to `#call` for
consistency, as that's the new standard we want to follow (see solidusio#4677 [2]
for an example). That's going to ease the adoption of a service layer if
we eventually introduce it.

[1] - solidusio#4460
[2] - solidusio#4677
  • Loading branch information
waiting-for-dev committed Jan 16, 2023
1 parent 26f1193 commit 413af46
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
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 @@ -197,7 +197,7 @@ def log_state_change(name)
end

def update_promotions
Spree::Config.promotion_adjuster_class.new(order).adjust!
Spree::Config.promotion_adjuster_class.new(order).call
end

# DEPRECATED; this functionality is handled in #update_promotions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def initialize(order)
@order = order
end

def adjust!
def call
all_items = line_items + shipments
all_items.each do |item|
promotion_adjustments = item.adjustments.select(&:promotion?)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
require 'rails_helper'

RSpec.describe Spree::Promotion::OrderAdjustmentsRecalculator do
subject { described_class.new(order).adjust! }
subject { described_class.new(order).call }

describe '#adjust! ' do
describe '#call ' do
describe 'promotion recalculation' do
let(:order) { create(:order_with_line_items, line_items_count: 1, line_items_price: 10) }
let(:line_item) { order.line_items[0] }
Expand Down

0 comments on commit 413af46

Please sign in to comment.