stripe 4.5.0 → 4.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -1
- data/CHANGELOG.md +3 -0
- data/VERSION +1 -1
- data/lib/stripe/account.rb +7 -2
- data/lib/stripe/version.rb +1 -1
- data/test/openapi/README.md +9 -0
- data/test/stripe/account_test.rb +51 -0
- data/test/stripe/stripe_object_test.rb +13 -10
- data/test/stripe_mock.rb +78 -0
- data/test/test_helper.rb +7 -2
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30001fb9ea2136d96728f5eac636ad6b86f787193fa18339ea0e594d8948d50c
|
4
|
+
data.tar.gz: 3eaf42ef3e0d39478fd7f386031cfd689df6b15c4d6005aafe93d733cf94ae45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1eb34606d76dbb884ce72323554009f4305c353ede914389b2e7a43bb297bccf39a30f4e7d32bcbf881c1adc1ae51df62f729c27ac253d83c585f38d951a4bdf
|
7
|
+
data.tar.gz: 17b31fdc7ab1d49e23b07e2882a121ee28e3116512a766a8323241ea8681cf02396c8b00a0a850cadafde3fb6b69431829cf3ca6c439cee5b46aa98218320379
|
data/.travis.yml
CHANGED
@@ -17,13 +17,15 @@ sudo: false
|
|
17
17
|
env:
|
18
18
|
global:
|
19
19
|
# If changing this number, please also change it in `test/test_helper.rb`.
|
20
|
-
- STRIPE_MOCK_VERSION=0.40.
|
20
|
+
- STRIPE_MOCK_VERSION=0.40.1
|
21
21
|
|
22
22
|
cache:
|
23
23
|
directories:
|
24
24
|
- stripe-mock
|
25
25
|
|
26
26
|
before_install:
|
27
|
+
# Install bundler 1.x, because we need to support Ruby 2.1 for now
|
28
|
+
- gem install bundler -v "~> 1.0"
|
27
29
|
# Unpack and start stripe-mock so that the test suite can talk to it
|
28
30
|
- |
|
29
31
|
if [ ! -d "stripe-mock/stripe-mock_${STRIPE_MOCK_VERSION}" ]; then
|
@@ -34,6 +36,7 @@ before_install:
|
|
34
36
|
- |
|
35
37
|
stripe-mock/stripe-mock_${STRIPE_MOCK_VERSION}/stripe-mock > /dev/null &
|
36
38
|
STRIPE_MOCK_PID=$!
|
39
|
+
- export PATH="${PATH}:${PWD}/stripe-mock/stripe-mock_${STRIPE_MOCK_VERSION}"
|
37
40
|
|
38
41
|
script:
|
39
42
|
- bundle exec rake
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 4.6.0 - 2019-01-21
|
4
|
+
* [#736](https://github.com/stripe/stripe-ruby/pull/736) Properly serialize `individual` on `Account` objects
|
5
|
+
|
3
6
|
## 4.5.0 - 2019-01-02
|
4
7
|
* [#719](https://github.com/stripe/stripe-ruby/pull/719) Generate OAuth authorize URLs for Express accounts as well as standard
|
5
8
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.
|
1
|
+
4.6.0
|
data/lib/stripe/account.rb
CHANGED
@@ -80,10 +80,10 @@ module Stripe
|
|
80
80
|
# We're trying to get this overturned on the server side, but for now,
|
81
81
|
# patch in a special allowance.
|
82
82
|
def serialize_params(options = {})
|
83
|
-
serialize_params_account(self, super)
|
83
|
+
serialize_params_account(self, super, options)
|
84
84
|
end
|
85
85
|
|
86
|
-
def serialize_params_account(_obj, update_hash)
|
86
|
+
def serialize_params_account(_obj, update_hash, options = {})
|
87
87
|
if (entity = @values[:legal_entity])
|
88
88
|
if (owners = entity[:additional_owners])
|
89
89
|
entity_update = update_hash[:legal_entity] ||= {}
|
@@ -91,6 +91,11 @@ module Stripe
|
|
91
91
|
serialize_additional_owners(entity, owners)
|
92
92
|
end
|
93
93
|
end
|
94
|
+
if (individual = @values[:individual])
|
95
|
+
if individual.is_a?(Person) && !update_hash.key?(:individual)
|
96
|
+
update_hash[:individual] = individual.serialize_params(options)
|
97
|
+
end
|
98
|
+
end
|
94
99
|
update_hash
|
95
100
|
end
|
96
101
|
|
data/lib/stripe/version.rb
CHANGED
@@ -0,0 +1,9 @@
|
|
1
|
+
## Using custom OpenAPI specification and fixtures files
|
2
|
+
|
3
|
+
You can place custom OpenAPI specification and fixtures files in this
|
4
|
+
directory. The files must be in JSON format, and must be named `spec3.json`
|
5
|
+
and `fixtures3.json` respectively.
|
6
|
+
|
7
|
+
If those files are present, the test suite will start its own stripe-mock
|
8
|
+
process on a random available port. In order for this to work, `stripe-mock`
|
9
|
+
must be on the `PATH` in the environment used to run the test suite.
|
data/test/stripe/account_test.rb
CHANGED
@@ -195,6 +195,57 @@ module Stripe
|
|
195
195
|
}
|
196
196
|
assert_equal(expected, obj.serialize_params)
|
197
197
|
end
|
198
|
+
|
199
|
+
should "serialize on a new individual" do
|
200
|
+
obj = Stripe::Util.convert_to_stripe_object({
|
201
|
+
object: "account",
|
202
|
+
}, {})
|
203
|
+
obj.individual = { first_name: "Jane" }
|
204
|
+
|
205
|
+
expected = { individual: { first_name: "Jane" } }
|
206
|
+
assert_equal(expected, obj.serialize_params)
|
207
|
+
end
|
208
|
+
|
209
|
+
should "serialize on a partially changed individual" do
|
210
|
+
obj = Stripe::Util.convert_to_stripe_object({
|
211
|
+
object: "account",
|
212
|
+
individual: Stripe::Util.convert_to_stripe_object({
|
213
|
+
object: "person",
|
214
|
+
first_name: "Jenny",
|
215
|
+
}, {}),
|
216
|
+
}, {})
|
217
|
+
obj.individual = { first_name: "Jane" }
|
218
|
+
|
219
|
+
expected = { individual: { first_name: "Jane" } }
|
220
|
+
assert_equal(expected, obj.serialize_params)
|
221
|
+
end
|
222
|
+
|
223
|
+
should "serialize on an unchanged individual" do
|
224
|
+
obj = Stripe::Util.convert_to_stripe_object({
|
225
|
+
object: "account",
|
226
|
+
individual: Stripe::Util.convert_to_stripe_object({
|
227
|
+
object: "person",
|
228
|
+
first_name: "Jenny",
|
229
|
+
}, {}),
|
230
|
+
}, {})
|
231
|
+
|
232
|
+
expected = { individual: {} }
|
233
|
+
assert_equal(expected, obj.serialize_params)
|
234
|
+
end
|
235
|
+
|
236
|
+
should "serialize on an unset individual" do
|
237
|
+
obj = Stripe::Util.convert_to_stripe_object({
|
238
|
+
object: "account",
|
239
|
+
individual: Stripe::Util.convert_to_stripe_object({
|
240
|
+
object: "person",
|
241
|
+
first_name: "Jenny",
|
242
|
+
}, {}),
|
243
|
+
}, {})
|
244
|
+
obj.individual = nil
|
245
|
+
|
246
|
+
expected = { individual: "" }
|
247
|
+
assert_equal(expected, obj.serialize_params)
|
248
|
+
end
|
198
249
|
end
|
199
250
|
end
|
200
251
|
end
|
@@ -159,18 +159,21 @@ module Stripe
|
|
159
159
|
|
160
160
|
context "#to_hash" do
|
161
161
|
should "skip calling to_hash on nil" do
|
162
|
-
|
163
|
-
|
164
|
-
|
162
|
+
begin
|
163
|
+
module NilWithToHash
|
164
|
+
def to_hash
|
165
|
+
raise "Can't call to_hash on nil"
|
166
|
+
end
|
165
167
|
end
|
168
|
+
::NilClass.include NilWithToHash
|
169
|
+
|
170
|
+
hash_with_nil = { id: 3, foo: nil }
|
171
|
+
obj = StripeObject.construct_from(hash_with_nil)
|
172
|
+
expected_hash = { id: 3, foo: nil }
|
173
|
+
assert_equal expected_hash, obj.to_hash
|
174
|
+
ensure
|
175
|
+
::NilClass.send(:undef_method, :to_hash)
|
166
176
|
end
|
167
|
-
# include is private in Ruby 2.0
|
168
|
-
NilClass.send(:include, NilWithToHash)
|
169
|
-
|
170
|
-
hash_with_nil = { id: 3, foo: nil }
|
171
|
-
obj = StripeObject.construct_from(hash_with_nil)
|
172
|
-
expected_hash = { id: 3, foo: nil }
|
173
|
-
assert_equal expected_hash, obj.to_hash
|
174
177
|
end
|
175
178
|
|
176
179
|
should "recursively call to_hash on its values" do
|
data/test/stripe_mock.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Stripe
|
4
|
+
class StripeMock
|
5
|
+
include Singleton
|
6
|
+
|
7
|
+
PATH_SPEC = "#{::File.dirname(__FILE__)}/openapi/spec3.json".freeze
|
8
|
+
PATH_FIXTURES = "#{::File.dirname(__FILE__)}/openapi/fixtures3.json".freeze
|
9
|
+
|
10
|
+
@pid = nil
|
11
|
+
@port = -1
|
12
|
+
|
13
|
+
# Starts stripe-mock, if necessary. Returns the port on which stripe-mock is listening.
|
14
|
+
def self.start
|
15
|
+
unless ::File.exist?(PATH_SPEC)
|
16
|
+
port = ENV["STRIPE_MOCK_PORT"] || 12_111
|
17
|
+
puts("No custom spec file found, assuming stripe-mock is already running on port #{port}")
|
18
|
+
return port
|
19
|
+
end
|
20
|
+
|
21
|
+
unless @pid.nil?
|
22
|
+
puts("stripe-mock already running on port #{@port}")
|
23
|
+
return @port
|
24
|
+
end
|
25
|
+
|
26
|
+
@port = find_available_port
|
27
|
+
|
28
|
+
puts("Starting stripe-mock on port #{@port}...")
|
29
|
+
|
30
|
+
@stdout, @child_stdout = ::IO.pipe
|
31
|
+
@stderr, @child_stderr = ::IO.pipe
|
32
|
+
|
33
|
+
@pid = ::Process.spawn(
|
34
|
+
["stripe-mock", "stripe-mock"],
|
35
|
+
"-http-port",
|
36
|
+
@port.to_s,
|
37
|
+
"-spec",
|
38
|
+
PATH_SPEC,
|
39
|
+
"-fixtures",
|
40
|
+
PATH_FIXTURES,
|
41
|
+
out: @child_stdout,
|
42
|
+
err: @child_stderr
|
43
|
+
)
|
44
|
+
|
45
|
+
[@child_stdout, @child_stderr].each(&:close)
|
46
|
+
|
47
|
+
sleep 1
|
48
|
+
|
49
|
+
status = (::Process.wait2(@pid, ::Process::WNOHANG) || []).last
|
50
|
+
if status.nil?
|
51
|
+
puts("Started stripe-mock, PID = #{@pid}")
|
52
|
+
else
|
53
|
+
abort("stripe-mock terminated early: #{status}")
|
54
|
+
end
|
55
|
+
|
56
|
+
@port
|
57
|
+
end
|
58
|
+
|
59
|
+
# Stops stripe-mock, if necessary.
|
60
|
+
def self.stop
|
61
|
+
return if @pid.nil?
|
62
|
+
puts("Stopping stripe-mock...")
|
63
|
+
::Process.kill(:SIGTERM, @pid)
|
64
|
+
::Process.waitpid2(@pid)
|
65
|
+
@pid = nil
|
66
|
+
@port = -1
|
67
|
+
puts("Stopped stripe-mock")
|
68
|
+
end
|
69
|
+
|
70
|
+
# Finds and returns an available TCP port
|
71
|
+
private_class_method def self.find_available_port
|
72
|
+
server = TCPServer.new("localhost", 0)
|
73
|
+
port = server.addr[1]
|
74
|
+
server.close
|
75
|
+
port
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -14,10 +14,11 @@ require "webmock/test_unit"
|
|
14
14
|
PROJECT_ROOT = ::File.expand_path("../../", __FILE__)
|
15
15
|
|
16
16
|
require ::File.expand_path("../test_data", __FILE__)
|
17
|
+
require ::File.expand_path("../stripe_mock", __FILE__)
|
17
18
|
|
18
19
|
# If changing this number, please also change it in `.travis.yml`.
|
19
|
-
MOCK_MINIMUM_VERSION = "0.40.
|
20
|
-
MOCK_PORT =
|
20
|
+
MOCK_MINIMUM_VERSION = "0.40.1".freeze
|
21
|
+
MOCK_PORT = Stripe::StripeMock.start
|
21
22
|
|
22
23
|
# Disable all real network connections except those that are outgoing to
|
23
24
|
# stripe-mock.
|
@@ -41,6 +42,10 @@ rescue Faraday::ConnectionFailed
|
|
41
42
|
"it running? Please see README for setup instructions.")
|
42
43
|
end
|
43
44
|
|
45
|
+
Test::Unit.at_exit do
|
46
|
+
Stripe::StripeMock.stop
|
47
|
+
end
|
48
|
+
|
44
49
|
module Test
|
45
50
|
module Unit
|
46
51
|
class TestCase
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stripe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stripe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -148,6 +148,7 @@ files:
|
|
148
148
|
- lib/stripe/webhook_endpoint.rb
|
149
149
|
- stripe.gemspec
|
150
150
|
- test/api_stub_helpers.rb
|
151
|
+
- test/openapi/README.md
|
151
152
|
- test/stripe/account_external_accounts_operations_test.rb
|
152
153
|
- test/stripe/account_link_test.rb
|
153
154
|
- test/stripe/account_login_links_operations_test.rb
|
@@ -224,6 +225,7 @@ files:
|
|
224
225
|
- test/stripe/util_test.rb
|
225
226
|
- test/stripe/webhook_endpoint_test.rb
|
226
227
|
- test/stripe/webhook_test.rb
|
228
|
+
- test/stripe_mock.rb
|
227
229
|
- test/stripe_test.rb
|
228
230
|
- test/test_data.rb
|
229
231
|
- test/test_helper.rb
|
@@ -247,12 +249,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
247
249
|
version: '0'
|
248
250
|
requirements: []
|
249
251
|
rubyforge_project:
|
250
|
-
rubygems_version: 2.7.
|
252
|
+
rubygems_version: 2.7.8
|
251
253
|
signing_key:
|
252
254
|
specification_version: 4
|
253
255
|
summary: Ruby bindings for the Stripe API
|
254
256
|
test_files:
|
255
257
|
- test/api_stub_helpers.rb
|
258
|
+
- test/openapi/README.md
|
256
259
|
- test/stripe/account_external_accounts_operations_test.rb
|
257
260
|
- test/stripe/account_link_test.rb
|
258
261
|
- test/stripe/account_login_links_operations_test.rb
|
@@ -329,6 +332,7 @@ test_files:
|
|
329
332
|
- test/stripe/util_test.rb
|
330
333
|
- test/stripe/webhook_endpoint_test.rb
|
331
334
|
- test/stripe/webhook_test.rb
|
335
|
+
- test/stripe_mock.rb
|
332
336
|
- test/stripe_test.rb
|
333
337
|
- test/test_data.rb
|
334
338
|
- test/test_helper.rb
|