diff --git a/core/app/models/spree/order.rb b/core/app/models/spree/order.rb index 7ce729868b8..9b6b9d73070 100644 --- a/core/app/models/spree/order.rb +++ b/core/app/models/spree/order.rb @@ -511,9 +511,7 @@ def create_proposed_shipments def apply_free_shipping_promotions Spree::PromotionHandler::FreeShipping.new(self).activate - shipments.each { |shipment| ItemAdjustments.new(shipment).update } - updater.update_shipment_total - persist_totals + update! end # Clean shipments and make order back to address state diff --git a/core/app/models/spree/order_contents.rb b/core/app/models/spree/order_contents.rb index 18c6d601d29..5c317dd9351 100644 --- a/core/app/models/spree/order_contents.rb +++ b/core/app/models/spree/order_contents.rb @@ -119,7 +119,6 @@ def after_add_or_remove(line_item, options = {}) shipment = options[:shipment] shipment.present? ? shipment.update_amounts : order.ensure_updated_shipments PromotionHandler::Cart.new(order, line_item).activate - ItemAdjustments.new(line_item).update reload_totals line_item end diff --git a/core/spec/models/spree/order_spec.rb b/core/spec/models/spree/order_spec.rb index 63ff4dfaf5f..a3d6923ce50 100644 --- a/core/spec/models/spree/order_spec.rb +++ b/core/spec/models/spree/order_spec.rb @@ -591,16 +591,12 @@ def merge!(other_order, user = nil) context "#apply_free_shipping_promotions" do it "calls out to the FreeShipping promotion handler" do - shipment = double('Shipment') - allow(order).to receive_messages shipments: [shipment] - expect(Spree::PromotionHandler::FreeShipping).to receive(:new).and_return(handler = double) - expect(handler).to receive(:activate) + expect_any_instance_of(Spree::PromotionHandler::FreeShipping).to( + receive(:activate) + ).and_call_original - expect(Spree::ItemAdjustments).to receive(:new).with(shipment).and_return(adjuster = double) - expect(adjuster).to receive(:update) + expect(order.updater).to receive(:update).and_call_original - expect(order.updater).to receive(:update_shipment_total) - expect(order.updater).to receive(:persist_totals) order.apply_free_shipping_promotions end end