From 5fd36e7eedf70f1bc7a062f2faadd79b29a7a0f0 Mon Sep 17 00:00:00 2001 From: Gaetan Craig-Riou Date: Wed, 7 Feb 2024 15:27:51 +1100 Subject: [PATCH] Fix SubscriptionConfirmJob spec Fix the payment stubbing, payment `process_offline!` was stubbed to return true and payment `completed?` was also stubbed to return true. `process_offline!` did not change the payment status in the database, meaning that any call to 'order.pending_payments' after that would return the payment which should have been processed offline, and therefore completed. This created some unwanted side effect, resulting in the test breaking. --- spec/jobs/subscription_confirm_job_spec.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spec/jobs/subscription_confirm_job_spec.rb b/spec/jobs/subscription_confirm_job_spec.rb index 237659e876..ff96e97a60 100644 --- a/spec/jobs/subscription_confirm_job_spec.rb +++ b/spec/jobs/subscription_confirm_job_spec.rb @@ -239,8 +239,11 @@ describe SubscriptionConfirmJob do context "when payments are processed without error" do before do - expect(payment).to receive(:process_offline!) { true } - expect(payment).to receive(:completed?) { true } + allow(payment).to receive(:process_offline!) do + # Mark payment as complete like it would be if sucessfully processed offline + payment.state = "complete" + true + end end it "sends only a subscription confirm email, no regular confirmation emails" do