From 1d1327e38eaabda10fd7821221c3aad2ee4e0248 Mon Sep 17 00:00:00 2001 From: Elia Schito Date: Thu, 7 Mar 2019 17:47:25 +0100 Subject: [PATCH 1/3] Align deprecation messages After update! => recalculate rename. ref: - https://github.com/solidusio/solidus/pull/1689 - https://github.com/solidusio/solidus/pull/2072 --- core/app/models/spree/order.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/app/models/spree/order.rb b/core/app/models/spree/order.rb index d0d7c7be25d..96874a1daff 100644 --- a/core/app/models/spree/order.rb +++ b/core/app/models/spree/order.rb @@ -366,11 +366,11 @@ def line_item_options_match(line_item, options) # Creates new tax charges if there are any applicable rates. If prices already # include taxes then price adjustments are created instead. - # @deprecated This now happens during #update! + # @deprecated This now happens during #recalculate def create_tax_charge! Spree::Config.tax_adjuster_class.new(self).adjust! end - deprecate create_tax_charge!: :update!, deprecator: Spree::Deprecation + deprecate create_tax_charge!: :recalculate, deprecator: Spree::Deprecation def reimbursement_total reimbursements.sum(:total) @@ -577,11 +577,12 @@ def shipping_eq_billing_address? bill_address == ship_address end + # @deprecated This now happens during #recalculate def set_shipments_cost shipments.each(&:update_amounts) recalculate end - deprecate set_shipments_cost: :update!, deprecator: Spree::Deprecation + deprecate set_shipments_cost: :recalculate, deprecator: Spree::Deprecation def is_risky? payments.risky.count > 0 From 0a04e8e3519d751cbdfe5e6f6e68dd272980c8ba Mon Sep 17 00:00:00 2001 From: Elia Schito Date: Fri, 10 May 2019 13:02:27 +0200 Subject: [PATCH 2/3] Order#recalculate already updates shipment amounts It does it in the OrderUpdater#update_shipment_amounts. --- core/app/models/spree/order.rb | 1 - core/spec/models/spree/order_spec.rb | 1 - 2 files changed, 2 deletions(-) diff --git a/core/app/models/spree/order.rb b/core/app/models/spree/order.rb index 96874a1daff..483008110ba 100644 --- a/core/app/models/spree/order.rb +++ b/core/app/models/spree/order.rb @@ -579,7 +579,6 @@ def shipping_eq_billing_address? # @deprecated This now happens during #recalculate def set_shipments_cost - shipments.each(&:update_amounts) recalculate end deprecate set_shipments_cost: :recalculate, deprecator: Spree::Deprecation diff --git a/core/spec/models/spree/order_spec.rb b/core/spec/models/spree/order_spec.rb index e68bcb96656..49db793cdb9 100644 --- a/core/spec/models/spree/order_spec.rb +++ b/core/spec/models/spree/order_spec.rb @@ -181,7 +181,6 @@ before { allow(order).to receive_messages shipments: [shipment] } it "update and persist totals" do - expect(shipment).to receive :update_amounts expect(order.updater).to receive :update Spree::Deprecation.silence do From 9aa2799d92a589f3d10a21e49da0ac50a329262f Mon Sep 17 00:00:00 2001 From: Elia Schito Date: Fri, 10 May 2019 13:07:18 +0200 Subject: [PATCH 3/3] Replace create_tax_charge! contents with recalculate OrderUpdater already does the same thing within update_taxes. --- core/app/models/spree/order.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/app/models/spree/order.rb b/core/app/models/spree/order.rb index 483008110ba..bde803c1d48 100644 --- a/core/app/models/spree/order.rb +++ b/core/app/models/spree/order.rb @@ -368,7 +368,7 @@ def line_item_options_match(line_item, options) # include taxes then price adjustments are created instead. # @deprecated This now happens during #recalculate def create_tax_charge! - Spree::Config.tax_adjuster_class.new(self).adjust! + recalculate end deprecate create_tax_charge!: :recalculate, deprecator: Spree::Deprecation