mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-23 05:28:53 +00:00
Invalidate all incomplete payments when creating a new one, not just those in "checkout" state.
Looking at prod data; when a checkout submission fails due to something like a card being out of date, the payment's state seems to be "pending" and not "checkout", which means this mechanism fro invalidating old payments is potentially not working where it should.
This commit is contained in:
@@ -49,6 +49,18 @@ describe Spree::Payment do
|
||||
end
|
||||
end
|
||||
|
||||
context "creating a new payment alongside other incomplete payments" do
|
||||
let(:order) { create(:order_with_totals) }
|
||||
let!(:incomplete_payment) { create(:payment, order: order, state: "pending") }
|
||||
let(:new_payment) { create(:payment, order: order, state: "checkout") }
|
||||
|
||||
it "invalidates other incomplete payments on the order" do
|
||||
new_payment
|
||||
|
||||
expect(incomplete_payment.reload.state).to eq "invalid"
|
||||
end
|
||||
end
|
||||
|
||||
# Regression test for https://github.com/spree/spree/pull/2224
|
||||
context 'failure' do
|
||||
it 'should transition to failed from pending state' do
|
||||
|
||||
Reference in New Issue
Block a user