stripe-rails 2.3.4 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 98454699702b467527128031422cf82e5e5cdd3a3f6fa7b883cc4fd8727d35dd
4
- data.tar.gz: 47982d0fd7a62bb8bd2e38e08fd83082ad0c5475e5bf474f8e9386057e1a1f54
3
+ metadata.gz: 4f877c1646308e099953867cf62109fc8274a9d452d4b1ddbaddacc421c5bc77
4
+ data.tar.gz: c6986a7464043e10d13580ad1149120931b794070640c4103368daa474580bf9
5
5
  SHA512:
6
- metadata.gz: c338725947f21b22a4f9d259142841bf586053b994b14c598b012674869dcfab1f34e89f8a68e53084c10fdc6055e536cc363b00dbcdff65d294ff77285198ad
7
- data.tar.gz: 0fd4604bfb3c91bb54d66d1fa7819431249c0d1576cac15fa9deb7cb6eb05fdb831099444729943d1f5e6f59718be929f7d9f7caa7aef3dd5e140280915c001b
6
+ metadata.gz: 132c1fec2a1510815e2694c0150a646cbec3d90f7bf8cb4b231ad209ba28e12e9b40ba2a89f77d75d8499b8a5559c332d4e5f6db9c20f3d4f4ff5b08601f6d7d
7
+ data.tar.gz: 43779b3dfbcfdeeb1ed74c14e783faf09b74dc81a8279a800c815cab4717bfc746d0a1da558853201546199545c25f991eaa44348c477418edae4cca63c3c7bf
@@ -14,12 +14,12 @@ jobs:
14
14
 
15
15
  strategy:
16
16
  matrix:
17
- ruby: [2.5.x, 2.6.x, 2.7.x]
17
+ ruby: [2.5.9, 2.6.10, 2.7.7]
18
18
  gemfile: [Gemfile, gemfiles/rails60.gemfile, gemfiles/rails52.gemfile, gemfiles/rails51.gemfile]
19
19
  steps:
20
20
  - uses: actions/checkout@v1
21
21
  - name: Set up Ruby
22
- uses: actions/setup-ruby@v1
22
+ uses: ruby/setup-ruby@v1
23
23
  with:
24
24
  ruby-version: ${{ matrix.ruby }}
25
25
  - name: Set up Code Climate
data/Changelog.md CHANGED
@@ -1,4 +1,11 @@
1
- ## Unreleased
1
+ ## 2.4.0 (2023-02-04)
2
+
3
+ - Add `tax_behavior` attribute to Price. Thanks @szechyjs !
4
+
5
+ ## 2.3.5 (2022-10-01)
6
+
7
+ - Fix some deprecation warnings in tests. Thanks @smtlaissezfaire !
8
+ - Fix `NameError when loading JavascriptHelper`. Thanks @smtlaissezfaire !
2
9
 
3
10
  ## 2.3.4 (2022-05-03)
4
11
 
data/Gemfile CHANGED
@@ -16,7 +16,7 @@ group :test do
16
16
  gem 'webmock'
17
17
  # System tests
18
18
  gem 'capybara'
19
- gem 'puma'
19
+ gem 'puma', '< 6' # https://github.com/teamcapybara/capybara/issues/2598
20
20
  gem 'selenium-webdriver'
21
21
  gem 'webdrivers'
22
22
  end
@@ -14,7 +14,7 @@ group :test do
14
14
  gem 'webmock'
15
15
  # Required for system tests
16
16
  gem 'capybara'
17
- gem 'puma'
17
+ gem 'puma', '< 6' # https://github.com/teamcapybara/capybara/issues/2598
18
18
  gem 'selenium-webdriver'
19
19
  gem 'webdrivers'
20
20
  end
@@ -14,7 +14,7 @@ group :test do
14
14
  gem 'webmock'
15
15
  # Required for system tests
16
16
  gem 'capybara'
17
- gem 'puma'
17
+ gem 'puma', '< 6' # https://github.com/teamcapybara/capybara/issues/2598
18
18
  gem 'selenium-webdriver'
19
19
  gem 'webdrivers'
20
20
  end
@@ -13,7 +13,7 @@ group :test do
13
13
  gem 'webmock'
14
14
  # Required for system tests
15
15
  gem 'capybara'
16
- gem 'puma'
16
+ gem 'puma', '< 6' # https://github.com/teamcapybara/capybara/issues/2598
17
17
  gem 'selenium-webdriver'
18
18
  gem 'webdrivers'
19
19
  end
data/lib/stripe/engine.rb CHANGED
@@ -79,7 +79,7 @@ environment file directly.
79
79
  end
80
80
  end
81
81
 
82
- initializer 'stripe.javascript_helper' do
82
+ config.to_prepare do
83
83
  ActiveSupport.on_load :action_controller do
84
84
  # ActionController::API does not have a helper method
85
85
  if respond_to?(:helper)
data/lib/stripe/prices.rb CHANGED
@@ -16,6 +16,7 @@ module Stripe
16
16
  :product_id,
17
17
  :recurring,
18
18
  :statement_descriptor,
19
+ :tax_behavior,
19
20
  :tiers,
20
21
  :tiers_mode,
21
22
  :transform_quantity,
@@ -40,6 +41,7 @@ module Stripe
40
41
  validates :billing_scheme, inclusion: { in: %w{ per_unit tiered } }, allow_nil: true
41
42
  validates :recurring_aggregate_usage, inclusion: { in: %w{ sum last_during_period last_ever max } }, allow_nil: true
42
43
  validates :recurring_usage_type, inclusion: { in: %w{ metered licensed } }, allow_nil: true
44
+ validates :tax_behavior, inclusion: { in: %w{ inclusive exclusive unspecified } }, allow_nil: true
43
45
  validates :tiers_mode, inclusion: { in: %w{ graduated volume } }, allow_nil: true
44
46
 
45
47
  validate :name_or_product_id
@@ -171,6 +173,7 @@ module Stripe
171
173
  tiers_mode: tiers_mode,
172
174
  billing_scheme: billing_scheme,
173
175
  lookup_key: @lookup_key,
176
+ tax_behavior: tax_behavior,
174
177
  transform_quantity: transform_quantity,
175
178
  }.merge(product_options).compact
176
179
  end
@@ -1,5 +1,5 @@
1
1
  module Stripe
2
2
  module Rails
3
- VERSION = '2.3.4'.freeze
3
+ VERSION = '2.4.0'.freeze
4
4
  end
5
5
  end
@@ -6,6 +6,12 @@ Stripe.price :gold do |price|
6
6
  }
7
7
  end
8
8
 
9
+ Stripe.price :taxable_gold do |price|
10
+ price.name = 'Taxable Gold'
11
+ price.unit_amount = 699
12
+ price.tax_behavior = 'exclusive'
13
+ end
14
+
9
15
  Stripe.price "Solid Gold".to_sym do |price|
10
16
  price.constant_name = 'SOLID_GOLD'
11
17
  price.name = 'Solid Gold'
@@ -307,7 +307,7 @@ describe 'building plans' do
307
307
 
308
308
  describe 'when passed invalid arguments for tiered pricing' do
309
309
  it 'raises a Stripe::InvalidConfigurationError when billing tiers are invalid' do
310
- lambda {
310
+ _(lambda {
311
311
  Stripe.plan "Bad Tiers".to_sym do |plan|
312
312
  plan.name = 'Acme as a service BAD TIERS'
313
313
  plan.constant_name = 'BAD_TIERS'
@@ -328,11 +328,11 @@ describe 'building plans' do
328
328
  }
329
329
  ]
330
330
  end
331
- }.must_raise Stripe::InvalidConfigurationError
331
+ }).must_raise Stripe::InvalidConfigurationError
332
332
  end
333
333
 
334
334
  it 'raises a Stripe::InvalidConfigurationError when billing tiers is not an array' do
335
- lambda {
335
+ _(lambda {
336
336
  Stripe.plan "Bad Tiers".to_sym do |plan|
337
337
  plan.name = 'Acme as a service BAD TIERS'
338
338
  plan.constant_name = 'BAD_TIERS'
@@ -348,7 +348,7 @@ describe 'building plans' do
348
348
  up_to: 10
349
349
  }
350
350
  end
351
- }.must_raise Stripe::InvalidConfigurationError
351
+ }).must_raise Stripe::InvalidConfigurationError
352
352
  end
353
353
  end
354
354
 
@@ -267,6 +267,46 @@ describe 'building prices' do
267
267
  }).must_raise Stripe::InvalidConfigurationError
268
268
  end
269
269
 
270
+ it 'denies invalid tax_behavior' do
271
+ _(lambda {
272
+ Stripe.price :broken do |price|
273
+ price.name = 'Invalid tax'
274
+ price.unit_amount = 999
275
+ price.tax_behavior = 'whatever'
276
+ end
277
+ }).must_raise Stripe::InvalidConfigurationError
278
+ end
279
+
280
+ it 'accepts a tax_behavior of exclusive' do
281
+ Stripe.price :exclusive do |price|
282
+ price.name = 'Exclusive tax'
283
+ price.unit_amount = 4800
284
+ price.tax_behavior = 'exclusive'
285
+ end
286
+
287
+ _(Stripe::Prices::EXCLUSIVE).wont_be_nil
288
+ end
289
+
290
+ it 'accepts a tax_behavior of inclusive' do
291
+ Stripe.price :inclusive do |price|
292
+ price.name = 'Inclusive tax'
293
+ price.unit_amount = 4800
294
+ price.tax_behavior = 'inclusive'
295
+ end
296
+
297
+ _(Stripe::Prices::INCLUSIVE).wont_be_nil
298
+ end
299
+
300
+ it 'accepts a tax_behavior of unspecified' do
301
+ Stripe.price :unspecified do |price|
302
+ price.name = 'Unspecified tax'
303
+ price.unit_amount = 4800
304
+ price.tax_behavior = 'unspecified'
305
+ end
306
+
307
+ _(Stripe::Prices::UNSPECIFIED).wont_be_nil
308
+ end
309
+
270
310
  describe 'name and product id validation' do
271
311
  it 'should be valid when using just the product id' do
272
312
  Stripe.price :prodded do |price|
@@ -322,6 +362,22 @@ describe 'building prices' do
322
362
  Stripe::Prices::GOLD.put!
323
363
  end
324
364
 
365
+ it 'creates a price with tax_behavior' do
366
+ Stripe::Price.expects(:create).with(
367
+ :lookup_key => 'taxable_gold',
368
+ :nickname => 'taxable_gold',
369
+ :currency => 'usd',
370
+ :product_data => {
371
+ :name => 'Taxable Gold',
372
+ :statement_descriptor => nil
373
+ },
374
+ :unit_amount => 699,
375
+ :recurring => {},
376
+ :tax_behavior => 'exclusive'
377
+ )
378
+ Stripe::Prices::TAXABLE_GOLD.put!
379
+ end
380
+
325
381
  it 'creates a price with an alternative currency' do
326
382
  Stripe::Price.expects(:create).with(
327
383
  :lookup_key => 'alternative_currency',
@@ -392,7 +448,7 @@ describe 'building prices' do
392
448
 
393
449
  describe 'when passed invalid arguments for tiered pricing' do
394
450
  it 'raises a Stripe::InvalidConfigurationError when billing tiers are invalid' do
395
- lambda {
451
+ _(lambda {
396
452
  Stripe.price "Bad Tiers".to_sym do |price|
397
453
  price.name = 'Acme as a service BAD TIERS'
398
454
  price.constant_name = 'BAD_TIERS'
@@ -414,11 +470,11 @@ describe 'building prices' do
414
470
  }
415
471
  ]
416
472
  end
417
- }.must_raise Stripe::InvalidConfigurationError
473
+ }).must_raise Stripe::InvalidConfigurationError
418
474
  end
419
475
 
420
476
  it 'raises a Stripe::InvalidConfigurationError when billing tiers is not an array' do
421
- lambda {
477
+ _(lambda {
422
478
  Stripe.price "Bad Tiers".to_sym do |price|
423
479
  price.name = 'Acme as a service BAD TIERS'
424
480
  price.constant_name = 'BAD_TIERS'
@@ -435,7 +491,7 @@ describe 'building prices' do
435
491
  up_to: 10
436
492
  }
437
493
  end
438
- }.must_raise Stripe::InvalidConfigurationError
494
+ }).must_raise Stripe::InvalidConfigurationError
439
495
  end
440
496
  end
441
497
 
data/test/spec_helper.rb CHANGED
@@ -34,6 +34,6 @@ if ActiveSupport::TestCase.method_defined?(:fixture_path=)
34
34
  end
35
35
 
36
36
  Stripe::Engine.testing = true
37
- require 'mocha/setup'
37
+ require 'mocha/minitest'
38
38
 
39
39
  require 'irb'
@@ -4,12 +4,18 @@ describe "Configuring the stripe engine" do
4
4
  i_suck_and_my_tests_are_order_dependent! # the default test must be run first!
5
5
 
6
6
  # 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
+ }
8
12
 
9
13
  let(:app) { Rails.application }
10
14
  let(:initializers) { STRIPE_INITIALIZER_NAMES.map{|name| app.initializers.find{|ini| ini.name == name } } }
11
15
 
12
- def rerun_initializers!; initializers.each{|init| init.run(app) }; end
16
+ def rerun_initializers!
17
+ initializers.each { |init| init.run(app) }
18
+ end
13
19
 
14
20
  after do
15
21
  Stripe.api_version = nil
@@ -60,11 +66,11 @@ describe "Configuring the stripe engine" do
60
66
  it "supports nil signing_secret" do
61
67
  subject
62
68
 
63
- app.config.stripe.signing_secret = nil
69
+ app.config.stripe.signing_secret = nil
64
70
  rerun_initializers!
65
71
 
66
- _(app.config.stripe.signing_secret).must_equal nil
67
- _(app.config.stripe.signing_secrets).must_equal nil
72
+ assert_nil app.config.stripe.signing_secret
73
+ assert_nil app.config.stripe.signing_secrets
68
74
  end
69
75
 
70
76
  it "supports multiple signing secrets" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stripe-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.4
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charles Lowell
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2022-05-03 00:00:00.000000000 Z
13
+ date: 2023-02-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -188,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
188
188
  - !ruby/object:Gem::Version
189
189
  version: '0'
190
190
  requirements: []
191
- rubygems_version: 3.1.6
191
+ rubygems_version: 3.3.24
192
192
  signing_key:
193
193
  specification_version: 4
194
194
  summary: A gem to integrate stripe into your rails app