Skip to content

Commit 003cb78

Browse files
Add :carton_shipped event
This adds a `:carton_shipped` event that is published whenever `OrderShipping#ship` succeeds to mark a carton as shipped. Co-Authored-By: Adam Mueller <[email protected]>
1 parent 1ae5336 commit 003cb78

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

core/app/models/spree/order_shipping.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ def ship(inventory_units:, stock_location:, address:, shipping_method:,
7272
@order.shipments.reload
7373
@order.recalculate
7474

75+
Spree::Bus.publish(:carton_shipped, carton:)
7576
carton
7677
end
7778

core/lib/spree/core/engine.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class Engine < ::Rails::Engine
6161
Spree::Bus.clear
6262

6363
%i[
64+
carton_shipped
6465
order_canceled
6566
order_emptied
6667
order_finalized

core/spec/models/spree/order_shipping_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ def emails
8585
it "sets the external_number" do
8686
expect(subject.external_number).to eq 'some-external-number'
8787
end
88+
89+
it "publishes a 'carton_shipped' event" do
90+
stub_spree_bus
91+
92+
expect(:carton_shipped).to have_been_published.with(carton: subject)
93+
end
8894
end
8995

9096
context "with a tracking number" do

0 commit comments

Comments
 (0)