mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
add spec to subscription confirm job
This commit is contained in:
@@ -134,6 +134,48 @@ describe SubscriptionConfirmJob do
|
||||
expect(job).to receive(:record_order)
|
||||
end
|
||||
|
||||
context "when Stripe payments need to be processed" do
|
||||
let(:charge_response_mock) do
|
||||
{ status: 200, body: JSON.generate(id: "ch_1234", object: "charge", amount: 2000) }
|
||||
end
|
||||
|
||||
before do
|
||||
allow(order).to receive(:payment_required?) { true }
|
||||
expect(job).to receive(:setup_payment!) { true }
|
||||
stub_request(:post, "https://api.stripe.com/v1/charges")
|
||||
.with(body: /amount/)
|
||||
.to_return(charge_response_mock)
|
||||
end
|
||||
|
||||
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) }
|
||||
|
||||
before do
|
||||
allow(order).to receive(:pending_payments) { [stripe_sca_payment] }
|
||||
expect(stripe_sca_payment_method).to receive(:charge_offline)
|
||||
end
|
||||
|
||||
it "runs the charges in offline mode" do
|
||||
job.send(:confirm_order!, order)
|
||||
end
|
||||
end
|
||||
|
||||
context "Stripe Connect" do
|
||||
let(:stripe_connect_payment_method) { create(:stripe_connect_payment_method) }
|
||||
let(:stripe_connect_payment) { create(:payment, amount: 10, payment_method: stripe_connect_payment_method) }
|
||||
|
||||
before do
|
||||
allow(order).to receive(:pending_payments) { [stripe_connect_payment] }
|
||||
expect(stripe_connect_payment_method).to receive(:charge_offline)
|
||||
end
|
||||
|
||||
it "runs the charges in offline mode" do
|
||||
job.send(:confirm_order!, order)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "when payments need to be processed" do
|
||||
let(:payment_method) { create(:payment_method) }
|
||||
let(:payment) { create(:payment, amount: 10) }
|
||||
|
||||
Reference in New Issue
Block a user