mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Restore removed spec to profile_storer_spec
This commit is contained in:
@@ -45,13 +45,14 @@ describe Spree::Admin::PaymentsController, type: :controller do
|
||||
end
|
||||
|
||||
context "with Stripe payment where payment.process! errors out" do
|
||||
let!(:payment_method) { create(:stripe_sca_payment_method, distributors: [shop]) }
|
||||
before do
|
||||
allow_any_instance_of(Spree::Payment).
|
||||
to receive(:process_offline!).
|
||||
and_raise(Spree::Core::GatewayError.new("Payment Gateway Error"))
|
||||
allow_any_instance_of(Spree::Payment).to receive(:authorize!) do |payment|
|
||||
payment.update state: "pending"
|
||||
end
|
||||
allow_any_instance_of(Spree::Payment).to receive(:process_offline!).
|
||||
and_raise(Spree::Core::GatewayError.new("Payment Gateway Error"))
|
||||
end
|
||||
|
||||
|
||||
it "redirects to new payment page with flash error" do
|
||||
spree_post :create, payment: params, order_id: order.number
|
||||
|
||||
|
||||
@@ -191,20 +191,26 @@ describe SubscriptionConfirmJob do
|
||||
end
|
||||
end
|
||||
|
||||
context "Stripe Connect" 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] }
|
||||
allow(stripe_sca_payment_method).to receive(:purchase) { true }
|
||||
allow(stripe_sca_payment_method).to receive(:provider) { provider }
|
||||
allow(stripe_sca_payment_method.provider).to receive(:purchase) { true }
|
||||
allow(stripe_sca_payment_method.provider).to receive(:capture) { true }
|
||||
end
|
||||
|
||||
it "runs the charges in offline mode" do
|
||||
job.send(:confirm_order!, order)
|
||||
expect(stripe_sca_payment_method).to have_received(:purchase)
|
||||
expect(stripe_sca_payment_method.provider).to have_received(:purchase)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -25,6 +25,19 @@ module Stripe
|
||||
stub_payment_method_attach_request(payment_method: card_id, customer: customer_id)
|
||||
end
|
||||
|
||||
context "when called from Stripe SCA" do
|
||||
let(:customer_response_body) {
|
||||
JSON.generate(id: customer_id, default_card: card_id, sources: { data: [{ id: "1" }] })
|
||||
}
|
||||
|
||||
it "fetches the customer id and the card id from the correct response fields" do
|
||||
profile_storer.create_customer_from_token
|
||||
|
||||
expect(payment.source.gateway_customer_profile_id).to eq customer_id
|
||||
expect(payment.source.gateway_payment_profile_id).to eq card_id
|
||||
end
|
||||
end
|
||||
|
||||
context "when called from Stripe SCA" do
|
||||
it "fetches the customer id and the card id from the correct response fields" do
|
||||
profile_storer.create_customer_from_token
|
||||
|
||||
Reference in New Issue
Block a user