mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Prevent exception when payment has been cleared
Note that in the real world, this avoids a crash, but still requires the user to click the button two more times before it will work, with no hints as to why. So not a great help.
This commit is contained in:
@@ -92,7 +92,10 @@ module Orders
|
||||
# Verifies if the in-memory payment state is different from the one stored in the database
|
||||
# This is be done without reloading the payment so that in-memory data is not changed
|
||||
def different_from_db_payment_state?(in_memory_payment_state, payment_id)
|
||||
in_memory_payment_state != Spree::Payment.find(payment_id).state
|
||||
# Re-load payment from the DB (unless it was cleared by clear_invalid_payments)
|
||||
db_payment = Spree::Payment.find_by(id: payment_id)
|
||||
|
||||
db_payment.present? && in_memory_payment_state != db_payment.state
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -368,8 +368,6 @@ RSpec.describe CheckoutController, type: :controller do
|
||||
end
|
||||
|
||||
it "deletes invalid (old) payments" do
|
||||
pending "#12693 ActiveRecord::RecordNotFound: Couldn't find Spree::Payment"
|
||||
|
||||
put(:update, params:)
|
||||
order.payments.reload
|
||||
expect(order.payments).not_to include other_payment
|
||||
|
||||
Reference in New Issue
Block a user