test that purchase is called by SCA and Connect providers

This commit is contained in:
Andy Brett
2020-12-16 08:08:03 -08:00
parent 934f4f278e
commit 7fc9cc9f31

View File

@@ -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