From 62fefd5d499c7d2a01ddbf4648213eba45744844 Mon Sep 17 00:00:00 2001 From: David Cook Date: Mon, 6 May 2024 12:11:11 +1000 Subject: [PATCH] Implement required method Most of the time this doesn't get called because source_required: false. But sometimes it [does happen](https://app.bugsnag.com/yaycode/openfoodnetwork-uk/errors/66329690f4b6380007e8a4f8) I have a feeling that source_required? could be moved to the superclass as payment_source_class.present?. But I don't know enough about this area of the system to try it... --- app/models/spree/payment_method/check.rb | 4 ++++ spec/controllers/checkout_controller_spec.rb | 9 ++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/models/spree/payment_method/check.rb b/app/models/spree/payment_method/check.rb index 9f4378830c..839698bebc 100644 --- a/app/models/spree/payment_method/check.rb +++ b/app/models/spree/payment_method/check.rb @@ -25,6 +25,10 @@ module Spree ActiveMerchant::Billing::Response.new(true, "", {}, {}) end + def payment_source_class + nil + end + def source_required? false end diff --git a/spec/controllers/checkout_controller_spec.rb b/spec/controllers/checkout_controller_spec.rb index b39ffdcacd..4930eb22d5 100644 --- a/spec/controllers/checkout_controller_spec.rb +++ b/spec/controllers/checkout_controller_spec.rb @@ -338,12 +338,11 @@ RSpec.describe CheckoutController, type: :controller do let!(:payment_method_id) { payment_method.id } it "updates and redirects to summary step" do - expect { put(:update, params:) }.to raise_error(RuntimeError, error_message) + put(:update, params:) - # according to Bugsnag, we should get an error 500 - expect(response.status).to be 200 - expect(response).not_to redirect_to checkout_step_path(:summary) - expect(order.reload.state).to eq "payment" + expect(response.status).to be 302 + expect(response).to redirect_to checkout_step_path(:summary) + expect(order.reload.state).to eq "confirmation" end end