mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
test that purchase is called by SCA and Connect providers
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user