mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Add spec for rescuing order saving shipment
This commit is contained in:
@@ -756,6 +756,24 @@ describe Spree::Order do
|
||||
|
||||
expect { order.next! }.to change { order.state }.from("delivery").to("payment")
|
||||
end
|
||||
|
||||
it "advances to complete state despite error" do
|
||||
advance_to_delivery_state(order)
|
||||
# advance to payment state
|
||||
order.next!
|
||||
|
||||
create(:payment, order: order)
|
||||
# https://github.com/openfoodfoundation/openfoodnetwork/issues/3924
|
||||
observed_error = ActiveRecord::RecordNotUnique.new(
|
||||
"PG::UniqueViolation",
|
||||
StandardError.new
|
||||
)
|
||||
expect(order.shipment).to receive(:save).and_call_original
|
||||
expect(order.shipment).to receive(:save).and_call_original
|
||||
expect(order.shipment).to receive(:save).and_raise(observed_error)
|
||||
|
||||
expect { order.next! }.to change { order.state }.from("payment").to("complete")
|
||||
end
|
||||
end
|
||||
|
||||
context "when the order is a subscription" do
|
||||
|
||||
Reference in New Issue
Block a user