diff --git a/core/app/models/spree/in_memory_order_updater.rb b/core/app/models/spree/in_memory_order_updater.rb index 172a4c603b..8d10f7ef5f 100644 --- a/core/app/models/spree/in_memory_order_updater.rb +++ b/core/app/models/spree/in_memory_order_updater.rb @@ -53,10 +53,10 @@ def recalculate(persist: true) end end - Spree::Bus.publish(:order_recalculated, order:) - persist_totals if persist end + + Spree::Bus.publish(:order_recalculated, order:) if persist end alias_method :update, :recalculate deprecate update: :recalculate, deprecator: Spree.deprecator diff --git a/core/app/models/spree/order_updater.rb b/core/app/models/spree/order_updater.rb index d5200ff3ed..063968ad22 100644 --- a/core/app/models/spree/order_updater.rb +++ b/core/app/models/spree/order_updater.rb @@ -27,9 +27,9 @@ def recalculate update_shipments recalculate_shipment_state end - Spree::Bus.publish(:order_recalculated, order:) persist_totals end + Spree::Bus.publish(:order_recalculated, order:) end alias_method :update, :recalculate deprecate update: :recalculate, deprecator: Spree.deprecator diff --git a/core/spec/models/spree/in_memory_order_updater_spec.rb b/core/spec/models/spree/in_memory_order_updater_spec.rb index c23ba7cb7e..80ff30bcda 100644 --- a/core/spec/models/spree/in_memory_order_updater_spec.rb +++ b/core/spec/models/spree/in_memory_order_updater_spec.rb @@ -632,6 +632,12 @@ module Spree expect(item).to have_received(:do_something) end + + it "does not fire the event when persist: false" do + updater.recalculate(persist: false) + + expect(item).not_to have_received(:do_something) + end end context "with invalid associated objects" do