Skip to content

Commit 5ec3778

Browse files
Fix DEPRECATION WARNING: Initialization autoloaded the constant Stripe::JavascriptHelper.
1 parent ec5b829 commit 5ec3778

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lib/stripe/engine.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def stripe_config.api_key=(key)
7979
end
8080
end
8181

82-
initializer 'stripe.javascript_helper' do
82+
config.to_prepare do
8383
ActiveSupport.on_load :action_controller do
8484
# ActionController::API does not have a helper method
8585
if respond_to?(:helper)

test/stripe_initializers_spec.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,18 @@
44
i_suck_and_my_tests_are_order_dependent! # the default test must be run first!
55

66
# NOTE: skipped `stripe.plans_and_coupons` to prevent warnings about constants
7-
STRIPE_INITIALIZER_NAMES = %w{ stripe.configure.defaults stripe.configure stripe.callbacks.eager_load stripe.javascript_helper }
7+
STRIPE_INITIALIZER_NAMES = %w{
8+
stripe.configure.defaults
9+
stripe.configure
10+
stripe.callbacks.eager_load
11+
}
812

913
let(:app) { Rails.application }
1014
let(:initializers) { STRIPE_INITIALIZER_NAMES.map{|name| app.initializers.find{|ini| ini.name == name } } }
1115

12-
def rerun_initializers!; initializers.each{|init| init.run(app) }; end
16+
def rerun_initializers!
17+
initializers.each { |init| init.run(app) }
18+
end
1319

1420
after do
1521
Stripe.api_version = nil

0 commit comments

Comments
 (0)