Fix JS error when Stripe connect is disabled but Stripe API keys are setup

This commit is contained in:
David Rodríguez
2025-10-21 17:04:53 +02:00
parent 69d8fc3cad
commit 802878b4eb
2 changed files with 16 additions and 1 deletions

View File

@@ -3,7 +3,7 @@
= inject_json_array("shops", @shops.all, Api::ShopForOrdersSerializer)
= inject_saved_credit_cards
- if Stripe.publishable_key
- if Spree::Config.stripe_connect_enabled && Stripe.publishable_key
:javascript
angular.module('Darkswarm').value("stripeObject", Stripe("#{Stripe.publishable_key}"))
angular.module('Darkswarm').value("stripePublishableKey", "#{Stripe.publishable_key}")

View File

@@ -112,6 +112,21 @@ RSpec.describe '
end
end
context "with Stripe setup" do
include StripeHelper
around do |example|
with_stripe_setup { example.call }
end
it "does not cause js errors even if Stripe connect is disabled" do
allow(Spree::Config).to receive(:stripe_connect_enabled).and_return(false)
visit "/account"
expect(page).to have_content "My account"
end
end
context "as a disabled user" do
before do
user.disabled = '1'