stripe-rails 1.10.0 → 2.1.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 +4 -4
- data/.github/pull_request_template.md +12 -1
- data/.github/workflows/ruby.yml +10 -7
- data/Changelog.md +25 -0
- data/Gemfile +3 -3
- data/README.md +8 -0
- data/gemfiles/{rails4.gemfile → rails51.gemfile} +6 -6
- data/gemfiles/rails52.gemfile +20 -0
- data/lib/stripe/callbacks.rb +3 -4
- data/lib/stripe/engine.rb +4 -4
- data/lib/stripe/rails/version.rb +1 -1
- data/stripe-rails.gemspec +2 -2
- data/test/callbacks_spec.rb +15 -15
- data/test/coupon_builder_spec.rb +4 -4
- data/test/dummy_apis_controller_spec.rb +1 -1
- data/test/events_controller_spec.rb +27 -8
- data/test/javascript_helper_spec.rb +12 -12
- data/test/plan_builder_spec.rb +35 -35
- data/test/product_builder_spec.rb +11 -11
- data/test/stripe_initializers_spec.rb +70 -27
- data/test/support/application_system_test_case.rb +2 -7
- data/test/testing_spec.rb +8 -8
- metadata +12 -17
- data/app/controllers/stripe/pings_controller.rb +0 -10
- data/app/models/stripe/ping.rb +0 -9
- data/test/pings_controller_spec.rb +0 -18
- data/test/support/null_system_test_case.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb58cd2c4b57bfb766859f950ea819137df7d25df3064654877db23a853fc181
|
4
|
+
data.tar.gz: b93b09f34648ff133397a56606a37bb5067130d19aef9007c823e13b993a4cfe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39ff75adfde760950733e00324423c99506d53f9cee614a7adc0ec61a2ea14758e9d9a1dc49a4cd2ceac83ed7c7597c8c276cb0cb169ba813c7e2de9da7fe237
|
7
|
+
data.tar.gz: 861343d690279311225fda2091e0d318c08c2c4c33e98d4fb73f9e528750a6751e7b0f07a2b1c43341da8a4011e4ff3618c3cee799445a38dd720bfab6d6b250
|
@@ -1,4 +1,15 @@
|
|
1
1
|
<!--
|
2
|
-
|
2
|
+
Thanks a bunch for helping out with the project!
|
3
|
+
|
4
|
+
Please remember to,
|
5
|
+
|
6
|
+
1. Add tests if they do not exist, fix em if they are breaking
|
7
|
+
2. Fix any issues that are stopping Code Climate from passing
|
8
|
+
2. Add a short description of the feature and tag yourself on Changelog.md
|
9
|
+
|
10
|
+
That's it!
|
11
|
+
|
12
|
+
Please give me ~1 week to get back to you.
|
13
|
+
|
3
14
|
If you'd like to receive occasional updates, sign up for our newsletter at http://tinyletter.com/stripe-rails
|
4
15
|
-->
|
data/.github/workflows/ruby.yml
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
name: Ruby
|
2
2
|
|
3
|
-
on:
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
pull_request:
|
8
|
+
branches:
|
9
|
+
- master
|
4
10
|
|
5
11
|
jobs:
|
6
12
|
build:
|
@@ -8,9 +14,8 @@ jobs:
|
|
8
14
|
|
9
15
|
strategy:
|
10
16
|
matrix:
|
11
|
-
ruby: [2.
|
12
|
-
gemfile: [Gemfile, gemfiles/
|
13
|
-
|
17
|
+
ruby: [2.5.x, 2.6.x, 2.7.x]
|
18
|
+
gemfile: [Gemfile, gemfiles/rails51.gemfile, gemfiles/rails52.gemfile]
|
14
19
|
steps:
|
15
20
|
- uses: actions/checkout@v1
|
16
21
|
- name: Set up Ruby
|
@@ -28,10 +33,8 @@ jobs:
|
|
28
33
|
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
|
29
34
|
RUBY_VERSION: ${{ matrix.ruby }}
|
30
35
|
run: |
|
31
|
-
gem uninstall bundler
|
32
|
-
gem install bundler -v 1.17.3
|
33
36
|
bundle install --jobs 4 --retry 3
|
34
37
|
bundle exec rake
|
35
|
-
if [ `basename $BUNDLE_GEMFILE` == "Gemfile" ] && [ $RUBY_VERSION == "2.
|
38
|
+
if [ `basename $BUNDLE_GEMFILE` == "Gemfile" ] && [ $RUBY_VERSION == "2.7.x" ] && [ ! -z ${CC_TEST_REPORTER_ID} ] ;
|
36
39
|
then ./cc-test-reporter after-build --exit-code $? ;
|
37
40
|
fi
|
data/Changelog.md
CHANGED
@@ -1,3 +1,28 @@
|
|
1
|
+
## 2.1.0 (2020-10-18)
|
2
|
+
|
3
|
+
- Added option to ignore missing API key and don't show any warning. Thanks @ndbroadbent!
|
4
|
+
- Handle passing nil to signing_secret= and add tests. Thanks @martron!
|
5
|
+
|
6
|
+
## 2.0.0 (2020-09-18)
|
7
|
+
|
8
|
+
- Everything from on the 2.0.0.pre release
|
9
|
+
- includes changes from the 1.10.2 release
|
10
|
+
|
11
|
+
## 1.10.2 (2020-09-18)
|
12
|
+
|
13
|
+
- adds missing callback `invoice.paid`. Thanks @SyborgStudios.
|
14
|
+
|
15
|
+
## 2.0.0.pre (2020-05-29)
|
16
|
+
|
17
|
+
* [Breaking] Updated to work only with Rails >= 5.1
|
18
|
+
* [Breaking] It'll only be tested on Ruby 2.7, 2.6 and 2.5.
|
19
|
+
* [Breaking] Supports the Stripe gem => 3.15.0 (from 2 years ago)
|
20
|
+
* [Breaking] Removes Stripe::PingsController controller.
|
21
|
+
|
22
|
+
## 1.10.1 (2020-05-29)
|
23
|
+
|
24
|
+
- adds missing callbacks for `payment_intent`. Thanks @klapperkopp .
|
25
|
+
|
1
26
|
## 1.10.0 (2020-03-31)
|
2
27
|
|
3
28
|
- Adds support for using multiple tiers in a plan, thanks @cpsoinos
|
data/Gemfile
CHANGED
@@ -14,9 +14,9 @@ group :test do
|
|
14
14
|
gem 'simplecov', '< 0.18', require: false
|
15
15
|
gem 'stripe-ruby-mock'
|
16
16
|
gem 'webmock'
|
17
|
-
#
|
17
|
+
# System tests
|
18
18
|
gem 'capybara'
|
19
|
-
gem 'webdrivers'
|
20
19
|
gem 'puma'
|
21
20
|
gem 'selenium-webdriver'
|
22
|
-
|
21
|
+
gem 'webdrivers'
|
22
|
+
end
|
data/README.md
CHANGED
@@ -137,6 +137,14 @@ you prefer to environment variables, you can also set `STRIPE_PUBLISHABLE_KEY`:
|
|
137
137
|
export STRIPE_PUBLISHABLE_KEY=pk_test_XXXYYYZZZ
|
138
138
|
```
|
139
139
|
|
140
|
+
If no API key is provided, `stripe-rails` will show a warning: "No stripe.com API key was configured ...". You can silence this warning by setting the `ignore_missing_secret_key` option to `true`:
|
141
|
+
|
142
|
+
```ruby
|
143
|
+
# config/environments/production.rb
|
144
|
+
# ...
|
145
|
+
config.stripe.ignore_missing_secret_key = true
|
146
|
+
```
|
147
|
+
|
140
148
|
### Manually set your API version (optional)
|
141
149
|
|
142
150
|
If you need to test a new API version in development, you can override the version number manually.
|
@@ -1,10 +1,10 @@
|
|
1
1
|
source :rubygems
|
2
2
|
|
3
|
-
gem 'rails', '~>
|
4
|
-
gem 'sprockets', '< 4'
|
3
|
+
gem 'rails', '~> 5.1.0'
|
5
4
|
|
6
5
|
gem 'rake'
|
7
|
-
gem 'responders'
|
6
|
+
gem 'responders'
|
7
|
+
gem 'sprockets', '< 4'
|
8
8
|
gem 'stripe'
|
9
9
|
|
10
10
|
group :test do
|
@@ -14,7 +14,7 @@ group :test do
|
|
14
14
|
gem 'webmock'
|
15
15
|
# Required for system tests
|
16
16
|
gem 'capybara'
|
17
|
-
gem '
|
18
|
-
gem 'puma'
|
17
|
+
gem 'puma'
|
19
18
|
gem 'selenium-webdriver'
|
20
|
-
|
19
|
+
gem 'webdrivers'
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
source :rubygems
|
2
|
+
|
3
|
+
gem 'rails', '~> 5.2.0'
|
4
|
+
|
5
|
+
gem 'rake'
|
6
|
+
gem 'responders'
|
7
|
+
gem 'sprockets', '< 4'
|
8
|
+
gem 'stripe'
|
9
|
+
|
10
|
+
group :test do
|
11
|
+
gem 'mocha'
|
12
|
+
gem 'simplecov', require: false
|
13
|
+
gem 'stripe-ruby-mock'
|
14
|
+
gem 'webmock'
|
15
|
+
# Required for system tests
|
16
|
+
gem 'capybara'
|
17
|
+
gem 'puma'
|
18
|
+
gem 'selenium-webdriver'
|
19
|
+
gem 'webdrivers'
|
20
|
+
end
|
data/lib/stripe/callbacks.rb
CHANGED
@@ -47,6 +47,7 @@ module Stripe
|
|
47
47
|
callback 'invoice.created'
|
48
48
|
callback 'invoice.finalized'
|
49
49
|
callback 'invoice.marked_uncollectible'
|
50
|
+
callback 'invoice.paid'
|
50
51
|
callback 'invoice.payment_action_required'
|
51
52
|
callback 'invoice.payment_failed'
|
52
53
|
callback 'invoice.payment_succeeded'
|
@@ -63,8 +64,10 @@ module Stripe
|
|
63
64
|
callback 'order.updated'
|
64
65
|
callback 'order_return.created'
|
65
66
|
callback 'payment_intent.amount_capturable_updated'
|
67
|
+
callback 'payment_intent.canceled'
|
66
68
|
callback 'payment_intent.created'
|
67
69
|
callback 'payment_intent.payment_failed'
|
70
|
+
callback 'payment_intent.processing'
|
68
71
|
callback 'payment_intent.succeeded'
|
69
72
|
callback 'payment_method.attached'
|
70
73
|
callback 'payment_method.card_automatically_updated'
|
@@ -103,10 +106,6 @@ module Stripe
|
|
103
106
|
callback 'ping'
|
104
107
|
callback 'stripe.event'
|
105
108
|
|
106
|
-
# Deprecated
|
107
|
-
callback 'transfer.failed' # https://stripe.com/docs/upgrades#2017-04-06
|
108
|
-
callback 'transfer.paid' # https://stripe.com/docs/upgrades#2017-04-06
|
109
|
-
|
110
109
|
class << self
|
111
110
|
def run_callbacks(evt, target)
|
112
111
|
_run_callbacks evt.type, evt, target
|
data/lib/stripe/engine.rb
CHANGED
@@ -8,12 +8,12 @@ module Stripe
|
|
8
8
|
attr_accessor :testing
|
9
9
|
end
|
10
10
|
|
11
|
-
stripe_config = config.stripe = Struct.new(:api_base, :api_version, :secret_key, :verify_ssl_certs, :signing_secret, :signing_secrets, :publishable_key, :endpoint, :debug_js, :auto_mount, :eager_load, :open_timeout, :read_timeout) do
|
11
|
+
stripe_config = config.stripe = Struct.new(:api_base, :api_version, :secret_key, :ignore_missing_secret_key, :verify_ssl_certs, :signing_secret, :signing_secrets, :publishable_key, :endpoint, :debug_js, :auto_mount, :eager_load, :open_timeout, :read_timeout) do
|
12
12
|
# for backwards compatibility treat signing_secret as an alias for signing_secrets
|
13
13
|
def signing_secret=(value)
|
14
|
-
self.signing_secrets = Array(value)
|
14
|
+
self.signing_secrets = value.nil? ? value : Array(value)
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
def signing_secret
|
18
18
|
self.signing_secrets && self.signing_secrets.first
|
19
19
|
end
|
@@ -43,7 +43,7 @@ module Stripe
|
|
43
43
|
end
|
44
44
|
secret_key = app.config.stripe.secret_key
|
45
45
|
Stripe.api_key = secret_key unless secret_key.nil?
|
46
|
-
$stderr.puts <<-MSG unless Stripe.api_key
|
46
|
+
$stderr.puts <<-MSG unless Stripe.api_key || app.config.stripe.ignore_missing_secret_key
|
47
47
|
No stripe.com API key was configured for environment #{::Rails.env}! this application will be
|
48
48
|
unable to interact with stripe.com. You can set your API key with either the environment
|
49
49
|
variable `STRIPE_SECRET_KEY` (recommended) or by setting `config.stripe.secret_key` in your
|
data/lib/stripe/rails/version.rb
CHANGED
data/stripe-rails.gemspec
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |gem|
|
|
14
14
|
gem.name = "stripe-rails"
|
15
15
|
gem.require_paths = ["lib"]
|
16
16
|
gem.version = Stripe::Rails::VERSION
|
17
|
-
gem.add_dependency 'rails', '>=
|
18
|
-
gem.add_dependency 'stripe', '>=
|
17
|
+
gem.add_dependency 'rails', '>= 5.1'
|
18
|
+
gem.add_dependency 'stripe', '>= 3.15.0'
|
19
19
|
gem.add_dependency 'responders'
|
20
20
|
end
|
data/test/callbacks_spec.rb
CHANGED
@@ -31,9 +31,9 @@ describe Stripe::Callbacks do
|
|
31
31
|
describe 'when it is invoked for the invoice.payment_succeeded event' do
|
32
32
|
it 'is invoked for the invoice.payment_succeeded event' do
|
33
33
|
subject
|
34
|
-
@event.wont_be_nil
|
35
|
-
@event.type.must_equal 'invoice.payment_succeeded'
|
36
|
-
@target.total.must_equal 6999
|
34
|
+
_(@event).wont_be_nil
|
35
|
+
_(@event.type).must_equal 'invoice.payment_succeeded'
|
36
|
+
_(@target.total).must_equal 6999
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -42,7 +42,7 @@ describe Stripe::Callbacks do
|
|
42
42
|
|
43
43
|
it 'the invoice.payment_succeeded callback is not invoked' do
|
44
44
|
subject
|
45
|
-
@event.must_be_nil
|
45
|
+
_(@event).must_be_nil
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -50,7 +50,7 @@ describe Stripe::Callbacks do
|
|
50
50
|
before { run_callback_with(callback) { fail } }
|
51
51
|
|
52
52
|
it 'causes the whole webhook to fail' do
|
53
|
-
->{ subject }.must_raise RuntimeError
|
53
|
+
_(-> { subject }).must_raise RuntimeError
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
@@ -61,8 +61,8 @@ describe Stripe::Callbacks do
|
|
61
61
|
|
62
62
|
it 'does not cause the webhook to fail' do
|
63
63
|
subject
|
64
|
-
last_response.status.must_be :>=, 200
|
65
|
-
last_response.status.must_be :<, 300
|
64
|
+
_(last_response.status).must_be :>=, 200
|
65
|
+
_(last_response.status).must_be :<, 300
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
@@ -75,7 +75,7 @@ describe Stripe::Callbacks do
|
|
75
75
|
|
76
76
|
it 'it will be run' do
|
77
77
|
subject
|
78
|
-
events.first.type.must_equal 'invoice.payment_failed'
|
78
|
+
_(events.first.type).must_equal 'invoice.payment_failed'
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
@@ -84,7 +84,7 @@ describe Stripe::Callbacks do
|
|
84
84
|
|
85
85
|
it 'it will be run' do
|
86
86
|
subject
|
87
|
-
events.first.type.must_equal 'foo.bar.baz'
|
87
|
+
_(events.first.type).must_equal 'foo.bar.baz'
|
88
88
|
end
|
89
89
|
end
|
90
90
|
end
|
@@ -109,7 +109,7 @@ describe Stripe::Callbacks do
|
|
109
109
|
describe 'when a prior attribute was not specified' do
|
110
110
|
it 'does not fire events' do
|
111
111
|
subject
|
112
|
-
events.length.must_equal 0
|
112
|
+
_(events.length).must_equal 0
|
113
113
|
end
|
114
114
|
end
|
115
115
|
|
@@ -117,7 +117,7 @@ describe Stripe::Callbacks do
|
|
117
117
|
before { @stubbed_event.data.previous_attributes['closed'] = true }
|
118
118
|
it 'fires events' do
|
119
119
|
subject
|
120
|
-
events.length.must_equal 1
|
120
|
+
_(events.length).must_equal 1
|
121
121
|
end
|
122
122
|
end
|
123
123
|
end
|
@@ -134,7 +134,7 @@ describe Stripe::Callbacks do
|
|
134
134
|
describe 'when a prior attribute was not specified' do
|
135
135
|
it 'does not fire events' do
|
136
136
|
subject
|
137
|
-
events.length.must_equal 0
|
137
|
+
_(events.length).must_equal 0
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
@@ -142,7 +142,7 @@ describe Stripe::Callbacks do
|
|
142
142
|
before { @stubbed_event.data.previous_attributes['subtotal'] = 699 }
|
143
143
|
it 'fire events' do
|
144
144
|
subject
|
145
|
-
events.length.must_equal 1
|
145
|
+
_(events.length).must_equal 1
|
146
146
|
end
|
147
147
|
end
|
148
148
|
end
|
@@ -159,7 +159,7 @@ describe Stripe::Callbacks do
|
|
159
159
|
describe 'when the lambda is not true' do
|
160
160
|
it 'does not fire events' do
|
161
161
|
subject
|
162
|
-
events.length.must_equal 0
|
162
|
+
_(events.length).must_equal 0
|
163
163
|
end
|
164
164
|
end
|
165
165
|
|
@@ -167,7 +167,7 @@ describe Stripe::Callbacks do
|
|
167
167
|
before { @stubbed_event.data.previous_attributes['closed'] = 'false' }
|
168
168
|
it 'fires events' do
|
169
169
|
subject
|
170
|
-
events.length.must_equal 1
|
170
|
+
_(events.length).must_equal 1
|
171
171
|
end
|
172
172
|
end
|
173
173
|
end
|
data/test/coupon_builder_spec.rb
CHANGED
@@ -13,7 +13,7 @@ describe 'building coupons' do
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
it "allows a single redemption by default" do
|
16
|
-
@coupon.max_redemptions.must_equal 1
|
16
|
+
_(@coupon.max_redemptions).must_equal 1
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -33,8 +33,8 @@ describe 'building coupons' do
|
|
33
33
|
after {Stripe::Coupons.send(:remove_const, :GOLD25)}
|
34
34
|
|
35
35
|
it 'is accessible via hash lookup (symbol/string agnostic)' do
|
36
|
-
Stripe::Coupons[:gold25].must_equal Stripe::Coupons::GOLD25
|
37
|
-
Stripe::Coupons['gold25'].must_equal Stripe::Coupons::GOLD25
|
36
|
+
_(Stripe::Coupons[:gold25]).must_equal Stripe::Coupons::GOLD25
|
37
|
+
_(Stripe::Coupons['gold25']).must_equal Stripe::Coupons::GOLD25
|
38
38
|
end
|
39
39
|
|
40
40
|
describe 'uploading' do
|
@@ -116,7 +116,7 @@ describe 'building coupons' do
|
|
116
116
|
end
|
117
117
|
describe 'with missing mandatory values' do
|
118
118
|
it 'raises an exception after configuring it' do
|
119
|
-
proc {Stripe.coupon(:bad) {}}.must_raise Stripe::InvalidConfigurationError
|
119
|
+
_(proc {Stripe.coupon(:bad) {}}).must_raise Stripe::InvalidConfigurationError
|
120
120
|
end
|
121
121
|
end
|
122
122
|
end
|
@@ -10,6 +10,10 @@ describe Stripe::EventsController do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
describe 'the events interface' do
|
13
|
+
subject { post '/stripe/events', params.to_json }
|
14
|
+
|
15
|
+
before { stripe_events_stub }
|
16
|
+
|
13
17
|
let(:params) {
|
14
18
|
{
|
15
19
|
id: 'evt_00000000000000',
|
@@ -17,14 +21,29 @@ describe Stripe::EventsController do
|
|
17
21
|
data: {object: 'customer'},
|
18
22
|
}
|
19
23
|
}
|
20
|
-
|
21
|
-
before do
|
24
|
+
let(:stripe_events_stub) do
|
22
25
|
stub_request(:get, "https://api.stripe.com/v1/events/evt_00000000000000").
|
23
26
|
to_return(status: 200, body: Stripe::Event.construct_from(params).to_json, headers: {})
|
24
27
|
end
|
25
|
-
subject { post '/stripe/events', params.to_json }
|
26
28
|
|
27
|
-
it { subject.must_be :ok? }
|
29
|
+
it { _(subject).must_be :ok? }
|
30
|
+
|
31
|
+
it 'should call the stripe_events_stub' do
|
32
|
+
subject
|
33
|
+
assert_requested(stripe_events_stub)
|
34
|
+
end
|
35
|
+
|
36
|
+
describe 'when signing_secret is nil' do
|
37
|
+
before do
|
38
|
+
header 'Stripe-Signature', 't=1537832721,v1=123,v0=123'
|
39
|
+
app.config.stripe.signing_secret = nil
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should call the stripe_events_stub' do
|
43
|
+
subject
|
44
|
+
assert_requested(stripe_events_stub)
|
45
|
+
end
|
46
|
+
end
|
28
47
|
end
|
29
48
|
|
30
49
|
describe 'signed webhooks' do
|
@@ -50,12 +69,12 @@ describe Stripe::EventsController do
|
|
50
69
|
|
51
70
|
it 'returns bad_request when invalid' do
|
52
71
|
Stripe::Webhook.expects(:construct_event).raises(Stripe::SignatureVerificationError.new('msg', 'sig_header'))
|
53
|
-
subject.must_be :bad_request?
|
72
|
+
_(subject).must_be :bad_request?
|
54
73
|
end
|
55
74
|
|
56
75
|
it 'returns ok when valid' do
|
57
76
|
Stripe::Webhook.expects(:construct_event).returns(Stripe::Event.construct_from(params))
|
58
|
-
subject.must_be :ok?
|
77
|
+
_(subject).must_be :ok?
|
59
78
|
end
|
60
79
|
end
|
61
80
|
|
@@ -82,12 +101,12 @@ describe Stripe::EventsController do
|
|
82
101
|
|
83
102
|
it 'returns bad_request when invalid' do
|
84
103
|
Stripe::Webhook.expects(:construct_event).twice.raises(Stripe::SignatureVerificationError.new('msg', 'sig_header'))
|
85
|
-
subject.must_be :bad_request?
|
104
|
+
_(subject).must_be :bad_request?
|
86
105
|
end
|
87
106
|
|
88
107
|
it 'returns ok when valid' do
|
89
108
|
Stripe::Webhook.expects(:construct_event).returns(Stripe::Event.construct_from(params))
|
90
|
-
subject.must_be :ok?
|
109
|
+
_(subject).must_be :ok?
|
91
110
|
end
|
92
111
|
end
|
93
112
|
end
|
@@ -8,13 +8,13 @@ describe Stripe::JavascriptHelper do
|
|
8
8
|
describe '#stripe_javascript_tag' do
|
9
9
|
describe 'when no options are passed' do
|
10
10
|
it 'should default to v3' do
|
11
|
-
view.stripe_javascript_tag.must_include 'https://js.stripe.com/v3/'
|
11
|
+
_(view.stripe_javascript_tag).must_include 'https://js.stripe.com/v3/'
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
describe 'when the v2 option is passed' do
|
16
16
|
it 'should default to v2' do
|
17
|
-
view.stripe_javascript_tag(:v2).must_include 'https://js.stripe.com/v2/'
|
17
|
+
_(view.stripe_javascript_tag(:v2)).must_include 'https://js.stripe.com/v2/'
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -22,12 +22,12 @@ describe Stripe::JavascriptHelper do
|
|
22
22
|
before { Rails.application.config.stripe.debug_js = true }
|
23
23
|
after { Rails.application.config.stripe.debug_js = false }
|
24
24
|
it 'should render the debug js' do
|
25
|
-
view.stripe_javascript_tag(:v1).must_include 'https://js.stripe.com/v1/stripe-debug.js'
|
25
|
+
_(view.stripe_javascript_tag(:v1)).must_include 'https://js.stripe.com/v1/stripe-debug.js'
|
26
26
|
end
|
27
27
|
|
28
28
|
describe 'when v3 is selected' do
|
29
29
|
it 'should not render debug js' do
|
30
|
-
view.stripe_javascript_tag(:v3).wont_include 'https://js.stripe.com/v1/stripe-debug.js'
|
30
|
+
_(view.stripe_javascript_tag(:v3)).wont_include 'https://js.stripe.com/v1/stripe-debug.js'
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -37,7 +37,7 @@ describe Stripe::JavascriptHelper do
|
|
37
37
|
subject { view.render :partial => 'stripe/js' }
|
38
38
|
|
39
39
|
it 'should render correctly' do
|
40
|
-
subject.must_include 'https://js.stripe.com/v3/'
|
40
|
+
_(subject).must_include 'https://js.stripe.com/v3/'
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -45,35 +45,35 @@ describe Stripe::JavascriptHelper do
|
|
45
45
|
subject { view.render :partial => 'stripe/js', locals: {stripe_js_version: 'v2'} }
|
46
46
|
|
47
47
|
it 'should render correctly' do
|
48
|
-
subject.must_include 'https://js.stripe.com/v2/'
|
48
|
+
_(subject).must_include 'https://js.stripe.com/v2/'
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
describe '#stripe_elements_tag' do
|
53
53
|
describe 'when no options are passed' do
|
54
54
|
it 'should display the form' do
|
55
|
-
view.stripe_elements_tag(
|
55
|
+
_(view.stripe_elements_tag(
|
56
56
|
submit_path: '/charge',
|
57
|
-
).must_include 'Credit or debit card'
|
57
|
+
)).must_include 'Credit or debit card'
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
61
|
describe 'with options' do
|
62
62
|
describe 'without default js' do
|
63
63
|
it 'wont include the default script tag' do
|
64
|
-
view.stripe_elements_tag(
|
64
|
+
_(view.stripe_elements_tag(
|
65
65
|
submit_path: '/charge',
|
66
66
|
js_path: 'another/path'
|
67
|
-
).wont_include '<script id="stripe_elements_js">'
|
67
|
+
)).wont_include '<script id="stripe_elements_js">'
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
71
|
describe 'without default css' do
|
72
72
|
it 'wont include the default style tag' do
|
73
|
-
view.stripe_elements_tag(
|
73
|
+
_(view.stripe_elements_tag(
|
74
74
|
submit_path: '/charge',
|
75
75
|
css_path: 'another/path'
|
76
|
-
).wont_include '<style>'
|
76
|
+
)).wont_include '<style>'
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
data/test/plan_builder_spec.rb
CHANGED
@@ -23,16 +23,16 @@ describe 'building plans' do
|
|
23
23
|
after { Stripe::Plans.send(:remove_const, :PRIMO) }
|
24
24
|
|
25
25
|
it 'is accessible via id' do
|
26
|
-
Stripe::Plans::PRIMO.wont_be_nil
|
26
|
+
_(Stripe::Plans::PRIMO).wont_be_nil
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'is accessible via collection' do
|
30
|
-
Stripe::Plans.all.must_include Stripe::Plans::PRIMO
|
30
|
+
_(Stripe::Plans.all).must_include Stripe::Plans::PRIMO
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'is accessible via hash lookup (symbol/string agnostic)' do
|
34
|
-
Stripe::Plans[:primo].must_equal Stripe::Plans::PRIMO
|
35
|
-
Stripe::Plans['primo'].must_equal Stripe::Plans::PRIMO
|
34
|
+
_(Stripe::Plans[:primo]).must_equal Stripe::Plans::PRIMO
|
35
|
+
_(Stripe::Plans['primo']).must_equal Stripe::Plans::PRIMO
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'accepts a billing interval of a day' do
|
@@ -42,7 +42,7 @@ describe 'building plans' do
|
|
42
42
|
plan.interval = 'day'
|
43
43
|
end
|
44
44
|
|
45
|
-
Stripe::Plans::DAILY.wont_be_nil
|
45
|
+
_(Stripe::Plans::DAILY).wont_be_nil
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'accepts a billing interval of a week' do
|
@@ -52,7 +52,7 @@ describe 'building plans' do
|
|
52
52
|
plan.interval = 'week'
|
53
53
|
end
|
54
54
|
|
55
|
-
Stripe::Plans::WEEKLY.wont_be_nil
|
55
|
+
_(Stripe::Plans::WEEKLY).wont_be_nil
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'accepts a billing interval of a month' do
|
@@ -62,7 +62,7 @@ describe 'building plans' do
|
|
62
62
|
plan.interval = 'month'
|
63
63
|
end
|
64
64
|
|
65
|
-
Stripe::Plans::MONTHLY.wont_be_nil
|
65
|
+
_(Stripe::Plans::MONTHLY).wont_be_nil
|
66
66
|
end
|
67
67
|
|
68
68
|
it 'accepts a billing interval of a year' do
|
@@ -72,17 +72,17 @@ describe 'building plans' do
|
|
72
72
|
plan.interval = 'year'
|
73
73
|
end
|
74
74
|
|
75
|
-
Stripe::Plans::YEARLY.wont_be_nil
|
75
|
+
_(Stripe::Plans::YEARLY).wont_be_nil
|
76
76
|
end
|
77
77
|
|
78
78
|
it 'denies arbitrary billing intervals' do
|
79
|
-
lambda {
|
79
|
+
_(lambda {
|
80
80
|
Stripe.plan :broken do |plan|
|
81
81
|
plan.name = 'Acme as a service BROKEN'
|
82
82
|
plan.amount = 999
|
83
83
|
plan.interval = 'anything'
|
84
84
|
end
|
85
|
-
}.must_raise Stripe::InvalidConfigurationError
|
85
|
+
}).must_raise Stripe::InvalidConfigurationError
|
86
86
|
end
|
87
87
|
|
88
88
|
it 'accepts a statement descriptor' do
|
@@ -93,55 +93,55 @@ describe 'building plans' do
|
|
93
93
|
plan.statement_descriptor = 'ACME Monthly'
|
94
94
|
end
|
95
95
|
|
96
|
-
Stripe::Plans::DESCRIBED.wont_be_nil
|
96
|
+
_(Stripe::Plans::DESCRIBED).wont_be_nil
|
97
97
|
end
|
98
98
|
|
99
99
|
it 'denies statement descriptors that are too long' do
|
100
|
-
lambda {
|
100
|
+
_(lambda {
|
101
101
|
Stripe.plan :described do |plan|
|
102
102
|
plan.name = 'Acme as a service'
|
103
103
|
plan.amount = 999
|
104
104
|
plan.interval = 'month'
|
105
105
|
plan.statement_descriptor = 'ACME as a Service Monthly'
|
106
106
|
end
|
107
|
-
}.must_raise Stripe::InvalidConfigurationError
|
107
|
+
}).must_raise Stripe::InvalidConfigurationError
|
108
108
|
end
|
109
109
|
|
110
110
|
it 'denies invalid values for active' do
|
111
|
-
lambda {
|
111
|
+
_(lambda {
|
112
112
|
Stripe.plan :broken do |plan|
|
113
113
|
plan.name = 'Acme as a service'
|
114
114
|
plan.amount = 999
|
115
115
|
plan.interval = 'month'
|
116
116
|
plan.active = 'whatever'
|
117
117
|
end
|
118
|
-
}.must_raise Stripe::InvalidConfigurationError
|
118
|
+
}).must_raise Stripe::InvalidConfigurationError
|
119
119
|
end
|
120
120
|
|
121
121
|
it 'denies invalid values for usage_type' do
|
122
|
-
lambda {
|
122
|
+
_(lambda {
|
123
123
|
Stripe.plan :broken do |plan|
|
124
124
|
plan.name = 'Acme as a service'
|
125
125
|
plan.amount = 999
|
126
126
|
plan.interval = 'month'
|
127
127
|
plan.usage_type = 'whatever'
|
128
128
|
end
|
129
|
-
}.must_raise Stripe::InvalidConfigurationError
|
129
|
+
}).must_raise Stripe::InvalidConfigurationError
|
130
130
|
end
|
131
131
|
|
132
132
|
it 'denies invalid values for aggregate_usage' do
|
133
|
-
lambda {
|
133
|
+
_(lambda {
|
134
134
|
Stripe.plan :broken do |plan|
|
135
135
|
plan.name = 'Acme as a service'
|
136
136
|
plan.amount = 999
|
137
137
|
plan.interval = 'month'
|
138
138
|
plan.aggregate_usage = 'whatever'
|
139
139
|
end
|
140
|
-
}.must_raise Stripe::InvalidConfigurationError
|
140
|
+
}).must_raise Stripe::InvalidConfigurationError
|
141
141
|
end
|
142
142
|
|
143
143
|
it 'denies aggregate_usage if usage type is liecensed' do
|
144
|
-
lambda {
|
144
|
+
_(lambda {
|
145
145
|
Stripe.plan :broken do |plan|
|
146
146
|
plan.name = 'Acme as a service'
|
147
147
|
plan.amount = 999
|
@@ -149,30 +149,30 @@ describe 'building plans' do
|
|
149
149
|
plan.usage_type = 'licensed'
|
150
150
|
plan.aggregate_usage = 'sum'
|
151
151
|
end
|
152
|
-
}.must_raise Stripe::InvalidConfigurationError
|
152
|
+
}).must_raise Stripe::InvalidConfigurationError
|
153
153
|
end
|
154
154
|
|
155
155
|
|
156
156
|
it 'denies invalid values for billing_scheme' do
|
157
|
-
lambda {
|
157
|
+
_(lambda {
|
158
158
|
Stripe.plan :broken do |plan|
|
159
159
|
plan.name = 'Acme as a service'
|
160
160
|
plan.amount = 999
|
161
161
|
plan.interval = 'month'
|
162
162
|
plan.billing_scheme = 'whatever'
|
163
163
|
end
|
164
|
-
}.must_raise Stripe::InvalidConfigurationError
|
164
|
+
}).must_raise Stripe::InvalidConfigurationError
|
165
165
|
end
|
166
166
|
|
167
167
|
it 'denies invalid values for tiers_mode' do
|
168
|
-
lambda {
|
168
|
+
_(lambda {
|
169
169
|
Stripe.plan :broken do |plan|
|
170
170
|
plan.name = 'Acme as a service'
|
171
171
|
plan.amount = 999
|
172
172
|
plan.interval = 'month'
|
173
173
|
plan.tiers_mode = 'whatever'
|
174
174
|
end
|
175
|
-
}.must_raise Stripe::InvalidConfigurationError
|
175
|
+
}).must_raise Stripe::InvalidConfigurationError
|
176
176
|
end
|
177
177
|
|
178
178
|
describe 'name and product id validation' do
|
@@ -182,18 +182,18 @@ describe 'building plans' do
|
|
182
182
|
plan.amount = 999
|
183
183
|
plan.interval = 'month'
|
184
184
|
end
|
185
|
-
Stripe::Plans::PRODDED.wont_be_nil
|
185
|
+
_(Stripe::Plans::PRODDED).wont_be_nil
|
186
186
|
end
|
187
187
|
|
188
188
|
it 'should be invalid when using both name and product id' do
|
189
|
-
lambda {
|
189
|
+
_(lambda {
|
190
190
|
Stripe.plan :broken do |plan|
|
191
191
|
plan.name = 'Acme as a service'
|
192
192
|
plan.product_id = 'acme'
|
193
193
|
plan.amount = 999
|
194
194
|
plan.interval = 'month'
|
195
195
|
end
|
196
|
-
}.must_raise Stripe::InvalidConfigurationError
|
196
|
+
}).must_raise Stripe::InvalidConfigurationError
|
197
197
|
end
|
198
198
|
end
|
199
199
|
|
@@ -419,7 +419,7 @@ describe 'building plans' do
|
|
419
419
|
|
420
420
|
describe 'with missing mandatory values' do
|
421
421
|
it 'raises an exception after configuring it' do
|
422
|
-
|
422
|
+
_(-> { Stripe.plan(:bad) {} }).must_raise Stripe::InvalidConfigurationError
|
423
423
|
end
|
424
424
|
end
|
425
425
|
|
@@ -446,28 +446,28 @@ describe 'building plans' do
|
|
446
446
|
after { Stripe::Plans.send(:remove_const, :PRIMO_PLAN) }
|
447
447
|
|
448
448
|
it 'is accessible via upcased constant_name' do
|
449
|
-
Stripe::Plans::PRIMO_PLAN.wont_be_nil
|
449
|
+
_(Stripe::Plans::PRIMO_PLAN).wont_be_nil
|
450
450
|
end
|
451
451
|
|
452
452
|
it 'is accessible via collection' do
|
453
|
-
Stripe::Plans.all.must_include Stripe::Plans::PRIMO_PLAN
|
453
|
+
_(Stripe::Plans.all).must_include Stripe::Plans::PRIMO_PLAN
|
454
454
|
end
|
455
455
|
|
456
456
|
it 'is accessible via hash lookup (symbol/string agnostic)' do
|
457
|
-
Stripe::Plans[:primo_plan].must_equal Stripe::Plans::PRIMO_PLAN
|
458
|
-
Stripe::Plans['primo_plan'].must_equal Stripe::Plans::PRIMO_PLAN
|
457
|
+
_(Stripe::Plans[:primo_plan]).must_equal Stripe::Plans::PRIMO_PLAN
|
458
|
+
_(Stripe::Plans['primo_plan']).must_equal Stripe::Plans::PRIMO_PLAN
|
459
459
|
end
|
460
460
|
|
461
461
|
describe 'constant name validation' do
|
462
462
|
it 'should be invalid when providing a constant name that can not be used for Ruby constant' do
|
463
|
-
lambda {
|
463
|
+
_(lambda {
|
464
464
|
Stripe.plan "Primo Plan".to_sym do |plan|
|
465
465
|
plan.name = 'Acme as a service PRIMO'
|
466
466
|
plan.constant_name = 'PRIMO PLAN'
|
467
467
|
plan.amount = 999
|
468
468
|
plan.interval = 'month'
|
469
469
|
end
|
470
|
-
}.must_raise Stripe::InvalidConfigurationError
|
470
|
+
}).must_raise Stripe::InvalidConfigurationError
|
471
471
|
end
|
472
472
|
end
|
473
473
|
|
@@ -15,16 +15,16 @@ describe 'building products' do
|
|
15
15
|
after { Stripe::Products.send(:remove_const, :PRIMO) }
|
16
16
|
|
17
17
|
it 'is accessible via id' do
|
18
|
-
Stripe::Products::PRIMO.wont_be_nil
|
18
|
+
_(Stripe::Products::PRIMO).wont_be_nil
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'is accessible via collection' do
|
22
|
-
Stripe::Products.all.must_include Stripe::Products::PRIMO
|
22
|
+
_(Stripe::Products.all).must_include Stripe::Products::PRIMO
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'is accessible via hash lookup (symbol/string agnostic)' do
|
26
|
-
Stripe::Products[:primo].must_equal Stripe::Products::PRIMO
|
27
|
-
Stripe::Products['primo'].must_equal Stripe::Products::PRIMO
|
26
|
+
_(Stripe::Products[:primo]).must_equal Stripe::Products::PRIMO
|
27
|
+
_(Stripe::Products['primo']).must_equal Stripe::Products::PRIMO
|
28
28
|
end
|
29
29
|
|
30
30
|
describe '.put!' do
|
@@ -63,42 +63,42 @@ describe 'building products' do
|
|
63
63
|
describe 'validations' do
|
64
64
|
describe 'with missing mandatory values' do
|
65
65
|
it 'raises an exception after configuring it' do
|
66
|
-
lambda { Stripe.product(:bad){} }.must_raise Stripe::InvalidConfigurationError
|
66
|
+
_(lambda { Stripe.product(:bad){} }).must_raise Stripe::InvalidConfigurationError
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
70
|
describe 'invalid type' do
|
71
71
|
it 'raises an exception during configuration' do
|
72
|
-
lambda {
|
72
|
+
_(lambda {
|
73
73
|
Stripe.product :broken do |product|
|
74
74
|
product.name = 'Acme as a service BROKEN'
|
75
75
|
product.type = 'anything'
|
76
76
|
end
|
77
|
-
}.must_raise Stripe::InvalidConfigurationError
|
77
|
+
}).must_raise Stripe::InvalidConfigurationError
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
81
|
describe 'when using an attribute only for goods' do
|
82
82
|
it 'raises an exception during configuration' do
|
83
|
-
lambda {
|
83
|
+
_(lambda {
|
84
84
|
Stripe.product :broken do |product|
|
85
85
|
product.name = 'Broken Service'
|
86
86
|
product.type = 'service'
|
87
87
|
product.caption = 'So good it is Primo'
|
88
88
|
end
|
89
|
-
}.must_raise Stripe::InvalidConfigurationError
|
89
|
+
}).must_raise Stripe::InvalidConfigurationError
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
93
|
describe 'when using an attribute only for services' do
|
94
94
|
it 'raises an exception during configuration' do
|
95
|
-
lambda {
|
95
|
+
_(lambda {
|
96
96
|
Stripe.product :broken do |product|
|
97
97
|
product.name = 'Broken Good'
|
98
98
|
product.type = 'good'
|
99
99
|
product.statement_descriptor = 'SERVICE'
|
100
100
|
end
|
101
|
-
}.must_raise Stripe::InvalidConfigurationError
|
101
|
+
}).must_raise Stripe::InvalidConfigurationError
|
102
102
|
end
|
103
103
|
end
|
104
104
|
end
|
@@ -12,23 +12,24 @@ describe "Configuring the stripe engine" do
|
|
12
12
|
def rerun_initializers!; initializers.each{|init| init.run(app) }; end
|
13
13
|
|
14
14
|
after do
|
15
|
-
Stripe.api_version
|
16
|
-
Stripe.api_base
|
17
|
-
Stripe.api_key
|
15
|
+
Stripe.api_version = nil
|
16
|
+
Stripe.api_base = 'https://api.stripe.com'
|
17
|
+
Stripe.api_key = 'XYZ'
|
18
|
+
ENV['STRIPE_SECRET_KEY'] = 'XYZ'
|
18
19
|
end
|
19
20
|
|
20
21
|
describe 'Stripe configurations' do
|
21
22
|
it "will have valid default values" do
|
22
|
-
Stripe.api_base.must_equal 'https://api.stripe.com'
|
23
|
-
Stripe.api_key.must_equal 'XYZ'
|
24
|
-
Stripe.api_version.must_be_nil
|
25
|
-
Stripe.verify_ssl_certs.must_equal true
|
26
|
-
Stripe.open_timeout.must_equal 30
|
27
|
-
Stripe.read_timeout.must_equal 80
|
28
|
-
|
29
|
-
app.config.stripe.endpoint.must_equal '/stripe'
|
30
|
-
app.config.stripe.auto_mount.must_equal true
|
31
|
-
app.config.stripe.debug_js.must_equal false
|
23
|
+
_(Stripe.api_base).must_equal 'https://api.stripe.com'
|
24
|
+
_(Stripe.api_key).must_equal 'XYZ'
|
25
|
+
_(Stripe.api_version).must_be_nil
|
26
|
+
_(Stripe.verify_ssl_certs).must_equal true
|
27
|
+
_(Stripe.open_timeout).must_equal 30
|
28
|
+
_(Stripe.read_timeout).must_equal 80
|
29
|
+
|
30
|
+
_(app.config.stripe.endpoint).must_equal '/stripe'
|
31
|
+
_(app.config.stripe.auto_mount).must_equal true
|
32
|
+
_(app.config.stripe.debug_js).must_equal false
|
32
33
|
end
|
33
34
|
|
34
35
|
subject do
|
@@ -40,20 +41,30 @@ describe "Configuring the stripe engine" do
|
|
40
41
|
app.config.stripe.open_timeout = 33
|
41
42
|
app.config.stripe.read_timeout = 88
|
42
43
|
rerun_initializers!
|
43
|
-
end
|
44
|
+
end
|
44
45
|
|
45
46
|
it "reads values that is set in the environment" do
|
46
47
|
subject
|
47
48
|
|
48
|
-
Stripe.api_base.must_equal 'http://localhost:5000'
|
49
|
-
Stripe.api_key.must_equal 'SECRET_XYZ'
|
50
|
-
Stripe.verify_ssl_certs.must_equal false
|
51
|
-
Stripe.api_version.must_equal '2015-10-16'
|
52
|
-
Stripe.open_timeout.must_equal 33
|
53
|
-
Stripe.read_timeout.must_equal 88
|
49
|
+
_(Stripe.api_base).must_equal 'http://localhost:5000'
|
50
|
+
_(Stripe.api_key).must_equal 'SECRET_XYZ'
|
51
|
+
_(Stripe.verify_ssl_certs).must_equal false
|
52
|
+
_(Stripe.api_version).must_equal '2015-10-16'
|
53
|
+
_(Stripe.open_timeout).must_equal 33
|
54
|
+
_(Stripe.read_timeout).must_equal 88
|
55
|
+
|
56
|
+
_(app.config.stripe.signing_secret).must_equal 'SIGNING_SECRET_XYZ'
|
57
|
+
_(app.config.stripe.signing_secrets.length).must_equal 1
|
58
|
+
end
|
59
|
+
|
60
|
+
it "supports nil signing_secret" do
|
61
|
+
subject
|
62
|
+
|
63
|
+
app.config.stripe.signing_secret = nil
|
64
|
+
rerun_initializers!
|
54
65
|
|
55
|
-
app.config.stripe.signing_secret.must_equal
|
56
|
-
app.config.stripe.signing_secrets.
|
66
|
+
_(app.config.stripe.signing_secret).must_equal nil
|
67
|
+
_(app.config.stripe.signing_secrets).must_equal nil
|
57
68
|
end
|
58
69
|
|
59
70
|
it "supports multiple signing secrets" do
|
@@ -62,8 +73,8 @@ describe "Configuring the stripe engine" do
|
|
62
73
|
app.config.stripe.signing_secrets = ['SIGNING_SECRET_XYZ', 'SIGNING_SECRET_XYZ_CONNECT']
|
63
74
|
rerun_initializers!
|
64
75
|
|
65
|
-
app.config.stripe.signing_secret.must_equal 'SIGNING_SECRET_XYZ'
|
66
|
-
app.config.stripe.signing_secrets.length.must_equal 2
|
76
|
+
_(app.config.stripe.signing_secret).must_equal 'SIGNING_SECRET_XYZ'
|
77
|
+
_(app.config.stripe.signing_secrets.length).must_equal 2
|
67
78
|
end
|
68
79
|
|
69
80
|
end
|
@@ -77,8 +88,8 @@ describe "Configuring the stripe engine" do
|
|
77
88
|
it 'should be eager loaded' do
|
78
89
|
subject
|
79
90
|
|
80
|
-
Dummy.const_defined?(:ModelWithCallbacks).must_equal true
|
81
|
-
Dummy.const_defined?(:ModuleWithCallbacks).must_equal true
|
91
|
+
_(Dummy.const_defined?(:ModelWithCallbacks)).must_equal true
|
92
|
+
_(Dummy.const_defined?(:ModuleWithCallbacks)).must_equal true
|
82
93
|
end
|
83
94
|
end
|
84
95
|
|
@@ -87,7 +98,39 @@ describe "Configuring the stripe engine" do
|
|
87
98
|
let(:warning_msg) { "[DEPRECATION] to align with stripe nomenclature, stripe.api_key has been renamed to config.stripe.secret_key\n" }
|
88
99
|
|
89
100
|
it 'should output a warning' do
|
90
|
-
-> { subject }.must_output '', warning_msg
|
101
|
+
_(-> { subject }).must_output '', warning_msg
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe 'missing stripe.secret_key' do
|
106
|
+
subject do
|
107
|
+
ENV['STRIPE_SECRET_KEY'] = nil
|
108
|
+
Stripe.api_key = nil
|
109
|
+
app.config.stripe.secret_key = nil
|
110
|
+
rerun_initializers!
|
111
|
+
end
|
112
|
+
let(:warning_msg) { /No stripe.com API key was configured for environment test!/ }
|
113
|
+
|
114
|
+
it 'should output a warning' do
|
115
|
+
_(-> { subject }).must_output '', warning_msg
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe 'stripe.ignore_missing_secret_key' do
|
120
|
+
subject do
|
121
|
+
ENV['STRIPE_SECRET_KEY'] = nil
|
122
|
+
Stripe.api_key = nil
|
123
|
+
app.config.stripe.secret_key = nil
|
124
|
+
app.config.stripe.ignore_missing_secret_key = true
|
125
|
+
rerun_initializers!
|
126
|
+
end
|
127
|
+
|
128
|
+
after do
|
129
|
+
app.config.stripe.ignore_missing_secret_key = false
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'should not output a warning' do
|
133
|
+
_(-> { subject }).must_output '', ''
|
91
134
|
end
|
92
135
|
end
|
93
136
|
end
|
@@ -1,8 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
# For Rails 4 compat
|
4
|
-
SystemTestCaseKlass = defined?(ActionDispatch::SystemTestCase) ? ActionDispatch::SystemTestCase : NullSystemTestCase
|
5
|
-
|
6
|
-
class ApplicationSystemTestCase < SystemTestCaseKlass
|
1
|
+
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
|
7
2
|
driven_by :selenium_chrome_headless
|
8
|
-
end
|
3
|
+
end
|
data/test/testing_spec.rb
CHANGED
@@ -28,8 +28,8 @@ describe "Testing" do
|
|
28
28
|
|
29
29
|
it 'the callback must run' do
|
30
30
|
subject
|
31
|
-
event.wont_be_nil
|
32
|
-
event.type.must_equal "invoice.payment_succeeded"
|
31
|
+
_(event).wont_be_nil
|
32
|
+
_(event.type).must_equal "invoice.payment_succeeded"
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -38,7 +38,7 @@ describe "Testing" do
|
|
38
38
|
|
39
39
|
it 'the callback must not run' do
|
40
40
|
subject
|
41
|
-
event.must_be_nil
|
41
|
+
_(event).must_be_nil
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -49,11 +49,11 @@ describe "Testing" do
|
|
49
49
|
|
50
50
|
it 'the callback should run with overwritten properties' do
|
51
51
|
subject
|
52
|
-
event.wont_be_nil
|
53
|
-
event.type.must_equal "invoice.payment_succeeded"
|
54
|
-
target.subtotal.must_equal 500
|
55
|
-
target.total.must_equal 1000
|
56
|
-
target.currency.must_equal "eur"
|
52
|
+
_(event).wont_be_nil
|
53
|
+
_(event.type).must_equal "invoice.payment_succeeded"
|
54
|
+
_(target.subtotal).must_equal 500
|
55
|
+
_(target.total).must_equal 1000
|
56
|
+
_(target.currency).must_equal "eur"
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stripe-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charles Lowell
|
8
8
|
- Nola Stowe
|
9
9
|
- SengMing Tan
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2020-
|
13
|
+
date: 2020-10-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -18,28 +18,28 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ">="
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
21
|
+
version: '5.1'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: '
|
28
|
+
version: '5.1'
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: stripe
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
33
|
- - ">="
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version:
|
35
|
+
version: 3.15.0
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version:
|
42
|
+
version: 3.15.0
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: responders
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,16 +78,15 @@ files:
|
|
78
78
|
- app/assets/stripe/stripe_elements.js
|
79
79
|
- app/controllers/stripe/application_controller.rb
|
80
80
|
- app/controllers/stripe/events_controller.rb
|
81
|
-
- app/controllers/stripe/pings_controller.rb
|
82
81
|
- app/helpers/stripe/javascript_helper.rb
|
83
82
|
- app/models/stripe/event_dispatch.rb
|
84
|
-
- app/models/stripe/ping.rb
|
85
83
|
- app/views/stripe/_elements.html.erb
|
86
84
|
- app/views/stripe/_elements_js.html.erb
|
87
85
|
- app/views/stripe/_js.html.erb
|
88
86
|
- config/locales/en.yml
|
89
87
|
- config/routes.rb
|
90
|
-
- gemfiles/
|
88
|
+
- gemfiles/rails51.gemfile
|
89
|
+
- gemfiles/rails52.gemfile
|
91
90
|
- lib/generators/stripe/install_generator.rb
|
92
91
|
- lib/generators/templates/coupons.rb
|
93
92
|
- lib/generators/templates/plans.rb
|
@@ -156,7 +155,6 @@ files:
|
|
156
155
|
- test/fixtures/stripe_plans_headers_2017.json
|
157
156
|
- test/invoice.json
|
158
157
|
- test/javascript_helper_spec.rb
|
159
|
-
- test/pings_controller_spec.rb
|
160
158
|
- test/plan_builder_spec.rb
|
161
159
|
- test/product_builder_spec.rb
|
162
160
|
- test/spec_helper.rb
|
@@ -164,13 +162,12 @@ files:
|
|
164
162
|
- test/support/application_system_test_case.rb
|
165
163
|
- test/support/callback_helpers.rb
|
166
164
|
- test/support/fixture_loader.rb
|
167
|
-
- test/support/null_system_test_case.rb
|
168
165
|
- test/testing_spec.rb
|
169
166
|
homepage: https://github.com/tansengming/stripe-rails
|
170
167
|
licenses:
|
171
168
|
- MIT
|
172
169
|
metadata: {}
|
173
|
-
post_install_message:
|
170
|
+
post_install_message:
|
174
171
|
rdoc_options: []
|
175
172
|
require_paths:
|
176
173
|
- lib
|
@@ -185,8 +182,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
182
|
- !ruby/object:Gem::Version
|
186
183
|
version: '0'
|
187
184
|
requirements: []
|
188
|
-
rubygems_version: 3.
|
189
|
-
signing_key:
|
185
|
+
rubygems_version: 3.1.2
|
186
|
+
signing_key:
|
190
187
|
specification_version: 4
|
191
188
|
summary: A gem to integrate stripe into your rails app
|
192
189
|
test_files:
|
@@ -239,7 +236,6 @@ test_files:
|
|
239
236
|
- test/fixtures/stripe_plans_headers_2017.json
|
240
237
|
- test/invoice.json
|
241
238
|
- test/javascript_helper_spec.rb
|
242
|
-
- test/pings_controller_spec.rb
|
243
239
|
- test/plan_builder_spec.rb
|
244
240
|
- test/product_builder_spec.rb
|
245
241
|
- test/spec_helper.rb
|
@@ -247,5 +243,4 @@ test_files:
|
|
247
243
|
- test/support/application_system_test_case.rb
|
248
244
|
- test/support/callback_helpers.rb
|
249
245
|
- test/support/fixture_loader.rb
|
250
|
-
- test/support/null_system_test_case.rb
|
251
246
|
- test/testing_spec.rb
|
data/app/models/stripe/ping.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Stripe::PingsController do
|
4
|
-
parallelize_me!
|
5
|
-
include Rack::Test::Methods
|
6
|
-
|
7
|
-
let(:app) { Rails.application }
|
8
|
-
before do
|
9
|
-
header 'Accept', 'application/json'
|
10
|
-
header 'Content-Type', 'application/json'
|
11
|
-
end
|
12
|
-
|
13
|
-
describe 'the ping interface' do
|
14
|
-
subject { get '/stripe/ping' }
|
15
|
-
|
16
|
-
it { subject.must_be :ok? }
|
17
|
-
end
|
18
|
-
end
|