From 7fc9cc9f31a310d5c7790e8aa4015b47f3de8d36 Mon Sep 17 00:00:00 2001 From: Andy Brett Date: Wed, 16 Dec 2020 08:08:03 -0800 Subject: [PATCH] test that purchase is called by SCA and Connect providers --- spec/jobs/subscription_confirm_job_spec.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/spec/jobs/subscription_confirm_job_spec.rb b/spec/jobs/subscription_confirm_job_spec.rb index 4eff7c9b61..cb34a16a99 100644 --- a/spec/jobs/subscription_confirm_job_spec.rb +++ b/spec/jobs/subscription_confirm_job_spec.rb @@ -150,14 +150,18 @@ describe SubscriptionConfirmJob do context "Stripe SCA" do let(:stripe_sca_payment_method) { create(:stripe_sca_payment_method) } let(:stripe_sca_payment) { create(:payment, amount: 10, payment_method: stripe_sca_payment_method) } + let(:provider) { double } before do + allow_any_instance_of(Stripe::CreditCardCloner).to receive(:find_or_clone) { ["cus_123", "pm_1234"] } allow(order).to receive(:pending_payments) { [stripe_sca_payment] } - expect(stripe_sca_payment_method).to receive(:charge_offline) + allow(stripe_sca_payment_method).to receive(:provider) { provider } + allow(stripe_sca_payment_method.provider).to receive(:purchase) { true } end it "runs the charges in offline mode" do job.send(:confirm_order!, order) + expect(stripe_sca_payment_method.provider).to have_received(:purchase) end end @@ -167,11 +171,12 @@ describe SubscriptionConfirmJob do before do allow(order).to receive(:pending_payments) { [stripe_connect_payment] } - expect(stripe_connect_payment_method).to receive(:charge_offline) + allow(stripe_connect_payment_method).to receive(:purchase) { true } end it "runs the charges in offline mode" do job.send(:confirm_order!, order) + expect(stripe_connect_payment_method).to have_received(:purchase) end end end