diff --git a/app/services/orders/workflow_service.rb b/app/services/orders/workflow_service.rb index 99eec1bd17..f0e84fbe18 100644 --- a/app/services/orders/workflow_service.rb +++ b/app/services/orders/workflow_service.rb @@ -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 diff --git a/spec/controllers/checkout_controller_spec.rb b/spec/controllers/checkout_controller_spec.rb index e444bd9730..4adbffa9df 100644 --- a/spec/controllers/checkout_controller_spec.rb +++ b/spec/controllers/checkout_controller_spec.rb @@ -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