From df09b68cfccc96d13284538346e2fd608c39abb9 Mon Sep 17 00:00:00 2001 From: Daniele Palombo Date: Fri, 13 Nov 2020 19:47:45 +0100 Subject: [PATCH] Remove deprecated method Spree::TaxRate#adjust in favour of Spree::Tax::orderAdjuster#adjust! https://github.com/solidusio/solidus/pull/3354 --- core/app/models/spree/tax_rate.rb | 17 ----- core/spec/models/spree/tax_rate_spec.rb | 92 ------------------------- 2 files changed, 109 deletions(-) diff --git a/core/app/models/spree/tax_rate.rb b/core/app/models/spree/tax_rate.rb index 627682f2d0f..e50b004872b 100644 --- a/core/app/models/spree/tax_rate.rb +++ b/core/app/models/spree/tax_rate.rb @@ -87,23 +87,6 @@ class TaxRate < Spree::Base end scope :included_in_price, -> { where(included_in_price: true) } - # Creates necessary tax adjustments for the order. - # - # @deprecated Please use `Spree::Tax::OrderAdjuster#adjust!` instead - def adjust(_order_tax_zone, item) - Spree::Deprecation.warn("`Spree::TaxRate#adjust` is deprecated. Please use `Spree::Tax::OrderAdjuster#adjust!` instead.", caller) - - amount = compute_amount(item) - - item.adjustments.create!( - source: self, - amount: amount, - order_id: item.order_id, - label: adjustment_label(amount), - included: included_in_price - ) - end - # This method is used by Adjustment#update to recalculate the cost. def compute_amount(item) calculator.compute(item) diff --git a/core/spec/models/spree/tax_rate_spec.rb b/core/spec/models/spree/tax_rate_spec.rb index 5411ecb6190..4fcd0ef5b11 100644 --- a/core/spec/models/spree/tax_rate_spec.rb +++ b/core/spec/models/spree/tax_rate_spec.rb @@ -187,98 +187,6 @@ end end - describe "#adjust" do - let(:taxable_address) { create(:address) } - let(:order) { create(:order_with_line_items, ship_address: order_address) } - let(:tax_zone) { create(:zone, countries: [taxable_address.country]) } - let(:foreign_address) { create(:address, country_iso_code: "CA") } - let!(:foreign_zone) { create(:zone, countries: [foreign_address.country]) } - let(:tax_rate) do - create(:tax_rate, - included_in_price: included_in_price, - show_rate_in_label: show_rate_in_label, - amount: 0.125, - zone: tax_zone) - end - - let(:item) { order.line_items.first } - - before do - expect(Spree::Deprecation).to receive(:warn). - with(/^`Spree::TaxRate#adjust` is deprecated/, any_args) - end - - describe 'adjustments' do - before do - tax_rate.adjust(nil, item) - end - - let(:adjustment_label) { item.adjustments.tax.first.label } - - context 'for included rates' do - let(:included_in_price) { true } - let(:order_address) { taxable_address } - - context 'with show rate in label' do - let(:show_rate_in_label) { true } - - it 'shows the rate in the label' do - expect(adjustment_label).to include("12.500%") - end - - it 'adds a remark that the rate is included in the price' do - expect(adjustment_label).to include("Included in Price") - end - end - - context 'with show rate in label turned off' do - let(:show_rate_in_label) { false } - - it 'does not show the rate in the label' do - expect(adjustment_label).not_to include("12.500%") - end - - it 'does not have two consecutive spaces' do - expect(adjustment_label).not_to include(" ") - end - - it 'adds a remark that the rate is included in the price' do - expect(adjustment_label).to include("Included in Price") - end - end - end - - context 'for additional rates' do - let(:included_in_price) { false } - let(:order_address) { taxable_address } - - context 'with show rate in label' do - let(:show_rate_in_label) { true } - - it 'shows the rate in the label' do - expect(adjustment_label).to include("12.500%") - end - - it 'does not add a remark that the rate is included in the price' do - expect(adjustment_label).not_to include("Included in Price") - end - end - - context 'with show rate in label turned off' do - let(:show_rate_in_label) { false } - - it 'does not show the rate in the label' do - expect(adjustment_label).not_to include("12.500%") - end - - it 'does not add a remark that the rate is included in the price' do - expect(adjustment_label).not_to include("Included in Price") - end - end - end - end - end - describe "#active?" do subject(:rate) { create(:tax_rate, validity).active? }