From 778524e0eba9d0fc2ec1298a5700d6e0f400622f Mon Sep 17 00:00:00 2001 From: John Cowhig <1895349+jcowhigjr@users.noreply.github.com> Date: Mon, 23 Aug 2021 14:47:10 -0400 Subject: [PATCH] Add expected payment state after admin update request Remove the pending/skipped spec that was previously throwing a stack level too deep error. Add a few more expectations to describe 422 payment.states to confirm the bug is gone. --- api/spec/requests/spree/api/payments_controller_spec.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/api/spec/requests/spree/api/payments_controller_spec.rb b/api/spec/requests/spree/api/payments_controller_spec.rb index 42a5d8777e4..33c12d64be2 100644 --- a/api/spec/requests/spree/api/payments_controller_spec.rb +++ b/api/spec/requests/spree/api/payments_controller_spec.rb @@ -157,6 +157,7 @@ module Spree put spree.api_order_payment_path(order, payment), params: { payment: { amount: 'invalid' } } expect(response.status).to eq(422) expect(json_response["error"]).to eq("Invalid resource. Please fix errors and try again.") + expect(payment.reload.state).to eq("pending") end it "returns a 403 status when the payment is not pending" do @@ -186,10 +187,6 @@ module Spree expect(response.status).to eq(422) expect(json_response["error"]).to eq "Invalid resource. Please fix errors and try again." expect(json_response["errors"]["base"][0]).to eq "Could not authorize card" - end - - it "does not raise a stack level error" do - skip "Investigate why a payment.reload after the request raises 'stack level too deep'" expect(payment.reload.state).to eq("failed") end end @@ -213,6 +210,7 @@ module Spree expect(response.status).to eq(422) expect(json_response["error"]).to eq "Invalid resource. Please fix errors and try again." expect(json_response["errors"]["base"][0]).to eq "Insufficient funds" + expect(payment.reload.state).to eq("failed") end end end @@ -235,6 +233,7 @@ module Spree expect(response.status).to eq(422) expect(json_response["error"]).to eq "Invalid resource. Please fix errors and try again." expect(json_response["errors"]["base"][0]).to eq "Insufficient funds" + expect(payment.reload.state).to eq("failed") end end end