Skip to content

Commit 5b738a8

Browse files
Remove deprecated method Spree::TaxRate#adjust
in favour of Spree::Tax::orderAdjuster#adjust! solidusio#3354
1 parent ea73132 commit 5b738a8

File tree

2 files changed

+0
-109
lines changed

2 files changed

+0
-109
lines changed

core/app/models/spree/tax_rate.rb

-17
Original file line numberDiff line numberDiff line change
@@ -87,23 +87,6 @@ class TaxRate < Spree::Base
8787
end
8888
scope :included_in_price, -> { where(included_in_price: true) }
8989

90-
# Creates necessary tax adjustments for the order.
91-
#
92-
# @deprecated Please use `Spree::Tax::OrderAdjuster#adjust!` instead
93-
def adjust(_order_tax_zone, item)
94-
Spree::Deprecation.warn("`Spree::TaxRate#adjust` is deprecated. Please use `Spree::Tax::OrderAdjuster#adjust!` instead.", caller)
95-
96-
amount = compute_amount(item)
97-
98-
item.adjustments.create!(
99-
source: self,
100-
amount: amount,
101-
order_id: item.order_id,
102-
label: adjustment_label(amount),
103-
included: included_in_price
104-
)
105-
end
106-
10790
# This method is used by Adjustment#update to recalculate the cost.
10891
def compute_amount(item)
10992
calculator.compute(item)

core/spec/models/spree/tax_rate_spec.rb

-92
Original file line numberDiff line numberDiff line change
@@ -187,98 +187,6 @@
187187
end
188188
end
189189

190-
describe "#adjust" do
191-
let(:taxable_address) { create(:address) }
192-
let(:order) { create(:order_with_line_items, ship_address: order_address) }
193-
let(:tax_zone) { create(:zone, countries: [taxable_address.country]) }
194-
let(:foreign_address) { create(:address, country_iso_code: "CA") }
195-
let!(:foreign_zone) { create(:zone, countries: [foreign_address.country]) }
196-
let(:tax_rate) do
197-
create(:tax_rate,
198-
included_in_price: included_in_price,
199-
show_rate_in_label: show_rate_in_label,
200-
amount: 0.125,
201-
zone: tax_zone)
202-
end
203-
204-
let(:item) { order.line_items.first }
205-
206-
before do
207-
expect(Spree::Deprecation).to receive(:warn).
208-
with(/^`Spree::TaxRate#adjust` is deprecated/, any_args)
209-
end
210-
211-
describe 'adjustments' do
212-
before do
213-
tax_rate.adjust(nil, item)
214-
end
215-
216-
let(:adjustment_label) { item.adjustments.tax.first.label }
217-
218-
context 'for included rates' do
219-
let(:included_in_price) { true }
220-
let(:order_address) { taxable_address }
221-
222-
context 'with show rate in label' do
223-
let(:show_rate_in_label) { true }
224-
225-
it 'shows the rate in the label' do
226-
expect(adjustment_label).to include("12.500%")
227-
end
228-
229-
it 'adds a remark that the rate is included in the price' do
230-
expect(adjustment_label).to include("Included in Price")
231-
end
232-
end
233-
234-
context 'with show rate in label turned off' do
235-
let(:show_rate_in_label) { false }
236-
237-
it 'does not show the rate in the label' do
238-
expect(adjustment_label).not_to include("12.500%")
239-
end
240-
241-
it 'does not have two consecutive spaces' do
242-
expect(adjustment_label).not_to include(" ")
243-
end
244-
245-
it 'adds a remark that the rate is included in the price' do
246-
expect(adjustment_label).to include("Included in Price")
247-
end
248-
end
249-
end
250-
251-
context 'for additional rates' do
252-
let(:included_in_price) { false }
253-
let(:order_address) { taxable_address }
254-
255-
context 'with show rate in label' do
256-
let(:show_rate_in_label) { true }
257-
258-
it 'shows the rate in the label' do
259-
expect(adjustment_label).to include("12.500%")
260-
end
261-
262-
it 'does not add a remark that the rate is included in the price' do
263-
expect(adjustment_label).not_to include("Included in Price")
264-
end
265-
end
266-
267-
context 'with show rate in label turned off' do
268-
let(:show_rate_in_label) { false }
269-
270-
it 'does not show the rate in the label' do
271-
expect(adjustment_label).not_to include("12.500%")
272-
end
273-
274-
it 'does not add a remark that the rate is included in the price' do
275-
expect(adjustment_label).not_to include("Included in Price")
276-
end
277-
end
278-
end
279-
end
280-
end
281-
282190
describe "#active?" do
283191
subject(:rate) { create(:tax_rate, validity).active? }
284192

0 commit comments

Comments
 (0)