Skip to content

Commit

Permalink
Merge pull request solidusio#5632 from mamhoff/deprecate-adjustment-r…
Browse files Browse the repository at this point in the history
…ecalculate

Deprecate Spree::Adjustment#recalculate
  • Loading branch information
tvdeyen authored Feb 27, 2024
2 parents b532f94 + 7ff5b8c commit 928781f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions core/app/models/spree/adjustment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ def recalculate
end
amount
end
deprecate :recalculate, deprecator: Spree.deprecator

# Calculates based on attached promotion (if this is a promotion
# adjustment) whether this promotion is still eligible.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
adjustment.source.tax_categories = []
end
adjustment.source.save
adjustment.recalculate
adjustment.update!(amount: adjustment.source.compute_amount(adjustment.adjustable))
end
end
end
Expand Down
6 changes: 6 additions & 0 deletions core/spec/models/spree/adjustment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@
let(:order) { create(:order_with_line_items, line_items_price: 100) }
let(:line_item) { order.line_items.to_a.first }

around do |example|
Spree.deprecator.silence do
example.run
end
end

context "when adjustment is finalized" do
let(:finalized) { true }

Expand Down

0 comments on commit 928781f

Please sign in to comment.