mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Merge pull request #9940 from filipefurtad0/fix_developer_settings_spec
Clears Stripe settings after example run
This commit is contained in:
@@ -28,9 +28,18 @@ module StripeHelper
|
||||
fill_in "cvc", with: "678"
|
||||
end
|
||||
|
||||
def setup_stripe
|
||||
Stripe.api_key = "sk_test_12345"
|
||||
Stripe.publishable_key = "pk_test_12345"
|
||||
def stripe_enable
|
||||
allow(Spree::Config).to receive(:stripe_connect_enabled).and_return(true)
|
||||
end
|
||||
|
||||
def with_stripe_setup(api_key = "sk_test_12345", publishable_key = "pk_test_12345")
|
||||
original_keys = [Stripe.api_key, Stripe.publishable_key]
|
||||
|
||||
Stripe.api_key = api_key
|
||||
Stripe.publishable_key = publishable_key
|
||||
|
||||
yield
|
||||
|
||||
Stripe.api_key, Stripe.publishable_key = original_keys
|
||||
end
|
||||
end
|
||||
|
||||
@@ -18,9 +18,11 @@ describe '
|
||||
create(:stripe_account, enterprise: order.distributor, stripe_user_id: "abc123")
|
||||
end
|
||||
|
||||
before { setup_stripe }
|
||||
around do |example|
|
||||
with_stripe_setup { example.run }
|
||||
end
|
||||
|
||||
context "making a new Stripe payment", js: true do
|
||||
context "making a new Stripe payment" do
|
||||
before do
|
||||
stub_payment_methods_post_request
|
||||
stub_payment_intent_get_request
|
||||
|
||||
@@ -30,8 +30,12 @@ describe "Check out with Stripe", js: true do
|
||||
calculator: Calculator::FlatRate.new(preferred_amount: 5.67))
|
||||
}
|
||||
|
||||
around do |example|
|
||||
with_stripe_setup { example.run }
|
||||
end
|
||||
|
||||
before do
|
||||
setup_stripe
|
||||
stripe_enable
|
||||
set_order order
|
||||
add_product_to_cart order, product
|
||||
distributor.shipping_methods << [shipping_with_fee, free_shipping]
|
||||
|
||||
@@ -644,8 +644,12 @@ describe "As a consumer, I want to checkout my order", js: true do
|
||||
end
|
||||
|
||||
context "for Stripe SCA", if: pay_method.eql?("Stripe SCA") do
|
||||
around do |example|
|
||||
with_stripe_setup { example.run }
|
||||
end
|
||||
|
||||
before do
|
||||
setup_stripe
|
||||
stripe_enable
|
||||
visit checkout_step_path(:payment)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user