Skip to content

Commit

Permalink
Write spec to test state_machine behavior.
Browse files Browse the repository at this point in the history
When `complete!` is called on order, it then updates all the shipments
to `ready`. The problem is that this update skips state_machine
transition callbacks. Write spec to show this behavior.
  • Loading branch information
Taylor Scott committed Jul 6, 2017
1 parent aa3d0e0 commit 4de3543
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion core/spec/models/spree/order/finalizing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@
end

it "should change the shipment state to ready if order is paid" do
Spree::Shipment.create(order: order)
Spree::Shipment.state_machine.after_transition to: :ready, do: :callback
shipment = Spree::Shipment.create(order: order)
expect(shipment).to receive(:callback)

order.shipments.reload

allow(order).to receive_messages(paid?: true, complete?: true)
Expand Down

0 comments on commit 4de3543

Please sign in to comment.