diff --git a/spec/controllers/admin/stripe_accounts_controller_spec.rb b/spec/controllers/admin/stripe_accounts_controller_spec.rb index 04a126b91b..53bfbf16a8 100644 --- a/spec/controllers/admin/stripe_accounts_controller_spec.rb +++ b/spec/controllers/admin/stripe_accounts_controller_spec.rb @@ -79,15 +79,9 @@ describe Admin::StripeAccountsController, type: :controller do describe "#status" do let(:params) { { format: :json, enterprise_id: enterprise.id } } - around do |example| - original_stripe_connect_enabled = Spree::Config[:stripe_connect_enabled] - example.run - Spree::Config.set(stripe_connect_enabled: original_stripe_connect_enabled) - end - before do Stripe.api_key = "sk_test_12345" - Spree::Config.set(stripe_connect_enabled: false) + allow(Spree::Config).to receive(:stripe_connect_enabled).and_return(false) end context "when I don't manage the specified enterprise" do @@ -117,7 +111,7 @@ describe Admin::StripeAccountsController, type: :controller do end context "when Stripe is enabled" do - before { Spree::Config.set(stripe_connect_enabled: true) } + before { allow(Spree::Config).to receive(:stripe_connect_enabled).and_return(true) } context "when no stripe account is associated with the specified enterprise" do it "returns with a status of 'account_missing'" do diff --git a/spec/models/spree/payment_method_spec.rb b/spec/models/spree/payment_method_spec.rb index 69554ff462..67801a7d4c 100644 --- a/spec/models/spree/payment_method_spec.rb +++ b/spec/models/spree/payment_method_spec.rb @@ -50,15 +50,9 @@ describe Spree::PaymentMethod do context "Stripe payment method" do let(:payment_method) { create(:stripe_sca_payment_method) } - around do |example| - original_stripe_connect_enabled = Spree::Config[:stripe_connect_enabled] - example.run - Spree::Config.set(stripe_connect_enabled: original_stripe_connect_enabled) - end - before do - Spree::Config.set(stripe_connect_enabled: true) - Stripe.publishable_key = "some_key" + allow(Spree::Config).to receive(:stripe_connect_enabled).and_return(true) + allow(Stripe).to receive(:publishable_key) { "some_key" } end context "and Stripe Connect is enabled and a Stripe publishable key, account id, account @@ -69,7 +63,7 @@ describe Spree::PaymentMethod do end context "and Stripe Connect is disabled" do - before { Spree::Config.set(stripe_connect_enabled: false) } + before { allow(Spree::Config).to receive(:stripe_connect_enabled).and_return(false) } it "returns false" do expect(payment_method).not_to be_configured @@ -77,7 +71,7 @@ describe Spree::PaymentMethod do end context "and a Stripe publishable key is not present" do - before { Spree::Config.set(stripe_connect_enabled: false) } + before { allow(Stripe).to receive(:publishable_key) { nil } } it "returns false" do expect(payment_method).not_to be_configured diff --git a/spec/requests/checkout/stripe_sca_spec.rb b/spec/requests/checkout/stripe_sca_spec.rb index 0c806e40d4..af703dabc7 100644 --- a/spec/requests/checkout/stripe_sca_spec.rb +++ b/spec/requests/checkout/stripe_sca_spec.rb @@ -82,18 +82,12 @@ describe "checking out an order with a Stripe SCA payment method", type: :reques } end - around do |example| - original_stripe_connect_enabled = Spree::Config[:stripe_connect_enabled] - example.run - Spree::Config.set(stripe_connect_enabled: original_stripe_connect_enabled) - end - before do order_cycle_distributed_variants = double(:order_cycle_distributed_variants) allow(OrderCycleDistributedVariants).to receive(:new) { order_cycle_distributed_variants } allow(order_cycle_distributed_variants).to receive(:distributes_order_variants?) { true } allow(Stripe).to receive(:publishable_key).and_return("some_token") - Spree::Config.set(stripe_connect_enabled: true) + allow(Spree::Config).to receive(:stripe_connect_enabled).and_return(true) Stripe.api_key = "sk_test_12345" order.update(distributor_id: enterprise.id, order_cycle_id: order_cycle.id) order.reload.update_totals diff --git a/spec/support/request/stripe_helper.rb b/spec/support/request/stripe_helper.rb index 0b17a89522..17d8893c2b 100644 --- a/spec/support/request/stripe_helper.rb +++ b/spec/support/request/stripe_helper.rb @@ -31,6 +31,6 @@ module StripeHelper def setup_stripe Stripe.api_key = "sk_test_12345" Stripe.publishable_key = "pk_test_12345" - Spree::Config.set(stripe_connect_enabled: true) + allow(Spree::Config).to receive(:stripe_connect_enabled).and_return(true) end end diff --git a/spec/system/admin/payment_method_spec.rb b/spec/system/admin/payment_method_spec.rb index c741c4849d..5af8257dd7 100644 --- a/spec/system/admin/payment_method_spec.rb +++ b/spec/system/admin/payment_method_spec.rb @@ -53,14 +53,8 @@ describe ' { id: "acc_connected123", business_name: "My Org", charges_enabled: true } } - around do |example| - original_stripe_connect_enabled = Spree::Config[:stripe_connect_enabled] - example.run - Spree::Config.set(stripe_connect_enabled: original_stripe_connect_enabled) - end - before do - Spree::Config.set(stripe_connect_enabled: true) + allow(Spree::Config).to receive(:stripe_connect_enabled).and_return(true) Stripe.api_key = "sk_test_12345" stub_request(:get, "https://api.stripe.com/v1/accounts/acc_connected123").to_return(body: JSON.generate(stripe_account_mock)) diff --git a/spec/system/consumer/account/cards_spec.rb b/spec/system/consumer/account/cards_spec.rb index 07e6422f73..14bd3c35be 100644 --- a/spec/system/consumer/account/cards_spec.rb +++ b/spec/system/consumer/account/cards_spec.rb @@ -18,19 +18,13 @@ describe "Credit Cards", js: true do create(:stored_credit_card, user_id: user.id, gateway_customer_profile_id: 'cus_FDTG') } - around do |example| - original_stripe_connect_enabled = Spree::Config[:stripe_connect_enabled] - example.run - Spree::Config.set(stripe_connect_enabled: original_stripe_connect_enabled) - end - before do login_as user allow(Stripe).to receive(:api_key).and_return("sk_test_12345") allow(Stripe.config).to receive(:api_key).and_return("sk_test_12345") allow(Stripe).to receive(:publishable_key).and_return("some_token") - Spree::Config.set(stripe_connect_enabled: true) + allow(Spree::Config).to receive(:stripe_connect_enabled).and_return(true) stub_request(:get, "https://api.stripe.com/v1/customers/cus_AZNMJ"). to_return(status: 200, body: JSON.generate(id: "cus_AZNMJ"))