Skip to content

Commit

Permalink
Merge pull request #220 from smtlaissezfaire/fix_deprecation_warnings
Browse files Browse the repository at this point in the history
Fix deprecation warnings + Fix autoload warning
  • Loading branch information
tansengming authored Sep 23, 2022
2 parents afc6455 + 383c81e commit 79d4490
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 15 deletions.
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## Unreleased

- Fix some deprecation warnings in tests. Thanks @smtlaissezfaire !
- Fix `NameError when loading JavascriptHelper`. Thanks @smtlaissezfaire !

## 2.3.4 (2022-05-03)

- Add setup_intent.canceled and setup_intent.requires_action callbacks. Thanks @jamesjason !
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def stripe_config.api_key=(key)
end
end

initializer 'stripe.javascript_helper' do
config.to_prepare do
ActiveSupport.on_load :action_controller do
# ActionController::API does not have a helper method
if respond_to?(:helper)
Expand Down
8 changes: 4 additions & 4 deletions test/plan_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@

describe 'when passed invalid arguments for tiered pricing' do
it 'raises a Stripe::InvalidConfigurationError when billing tiers are invalid' do
lambda {
_(lambda {
Stripe.plan "Bad Tiers".to_sym do |plan|
plan.name = 'Acme as a service BAD TIERS'
plan.constant_name = 'BAD_TIERS'
Expand All @@ -328,11 +328,11 @@
}
]
end
}.must_raise Stripe::InvalidConfigurationError
}).must_raise Stripe::InvalidConfigurationError
end

it 'raises a Stripe::InvalidConfigurationError when billing tiers is not an array' do
lambda {
_(lambda {
Stripe.plan "Bad Tiers".to_sym do |plan|
plan.name = 'Acme as a service BAD TIERS'
plan.constant_name = 'BAD_TIERS'
Expand All @@ -348,7 +348,7 @@
up_to: 10
}
end
}.must_raise Stripe::InvalidConfigurationError
}).must_raise Stripe::InvalidConfigurationError
end
end

Expand Down
8 changes: 4 additions & 4 deletions test/price_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@

describe 'when passed invalid arguments for tiered pricing' do
it 'raises a Stripe::InvalidConfigurationError when billing tiers are invalid' do
lambda {
_(lambda {
Stripe.price "Bad Tiers".to_sym do |price|
price.name = 'Acme as a service BAD TIERS'
price.constant_name = 'BAD_TIERS'
Expand All @@ -414,11 +414,11 @@
}
]
end
}.must_raise Stripe::InvalidConfigurationError
}).must_raise Stripe::InvalidConfigurationError
end

it 'raises a Stripe::InvalidConfigurationError when billing tiers is not an array' do
lambda {
_(lambda {
Stripe.price "Bad Tiers".to_sym do |price|
price.name = 'Acme as a service BAD TIERS'
price.constant_name = 'BAD_TIERS'
Expand All @@ -435,7 +435,7 @@
up_to: 10
}
end
}.must_raise Stripe::InvalidConfigurationError
}).must_raise Stripe::InvalidConfigurationError
end
end

Expand Down
2 changes: 1 addition & 1 deletion test/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
end

Stripe::Engine.testing = true
require 'mocha/setup'
require 'mocha/minitest'

require 'irb'
16 changes: 11 additions & 5 deletions test/stripe_initializers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@
i_suck_and_my_tests_are_order_dependent! # the default test must be run first!

# NOTE: skipped `stripe.plans_and_coupons` to prevent warnings about constants
STRIPE_INITIALIZER_NAMES = %w{ stripe.configure.defaults stripe.configure stripe.callbacks.eager_load stripe.javascript_helper }
STRIPE_INITIALIZER_NAMES = %w{
stripe.configure.defaults
stripe.configure
stripe.callbacks.eager_load
}

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

def rerun_initializers!; initializers.each{|init| init.run(app) }; end
def rerun_initializers!
initializers.each { |init| init.run(app) }
end

after do
Stripe.api_version = nil
Expand Down Expand Up @@ -60,11 +66,11 @@ def rerun_initializers!; initializers.each{|init| init.run(app) }; end
it "supports nil signing_secret" do
subject

app.config.stripe.signing_secret = nil
app.config.stripe.signing_secret = nil
rerun_initializers!

_(app.config.stripe.signing_secret).must_equal nil
_(app.config.stripe.signing_secrets).must_equal nil
assert_nil app.config.stripe.signing_secret
assert_nil app.config.stripe.signing_secrets
end

it "supports multiple signing secrets" do
Expand Down

0 comments on commit 79d4490

Please sign in to comment.