stripe 2.10.0 → 2.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e6ecda0a77dd1fdbc7115558111b52e5afe5e882
4
- data.tar.gz: 43003db2cf79373969adef18730c88bb5f60cb76
3
+ metadata.gz: 6354295ff3cc3d9d5b42cfd49aaa9371cdac40a8
4
+ data.tar.gz: 9b306be44b4df38c53ac0db5ba98101135958b8c
5
5
  SHA512:
6
- metadata.gz: 5593a4c1469cdf72619d53eba85fb47c1909167bfa357ee5868b4bd34b58ca3535d46af1e0e01e0b9d6d4ec5aec7ec95c545e6c7962936dd398a3a57d1679251
7
- data.tar.gz: 9dce85148f7bbf3f0c2ce8eb826ad34f37e75ff41cb003678997c52c0d73ea855d44ce543d33c755ecc365ad067b9475fe9cb64dc3e1e2507d8ca0cc52e1bb12
6
+ metadata.gz: 72fe2684cc86a668f417ec87156c79e84401dbbc72b33d46836eee737e427ddfb838ad78cb4fe6517d3e064e4ffd9538d3634fc153def9ca874b60a3ddb505dc
7
+ data.tar.gz: 073939a037d90f8daf19740cf639c1a1aa09e9996b1510e2eb2ce79fccd083f757d7211d6034a16b0704b199895d0a53108995143a813e28be6abf209b4aaf77
@@ -1,3 +1,7 @@
1
+ === 2.11.0 2017-05-26
2
+
3
+ * Warn when keys that look like opts are included as parameters
4
+
1
5
  === 2.10.0 2017-05-25
2
6
 
3
7
  * Add support for account login links
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.10.0
1
+ 2.11.0
@@ -5,6 +5,8 @@ module Stripe
5
5
  OPTS_KEYS_TO_PERSIST = Set[:api_key, :api_base, :client, :stripe_account, :stripe_version]
6
6
 
7
7
  def request(method, url, params={}, opts={})
8
+ warn_on_opts_in_params(params)
9
+
8
10
  opts = Util.normalize_opts(opts)
9
11
  opts[:client] ||= StripeClient.active_client
10
12
 
@@ -30,6 +32,19 @@ module Stripe
30
32
 
31
33
  [resp, opts_to_persist]
32
34
  end
35
+
36
+ private
37
+
38
+ KNOWN_OPTS = Set[:api_key, :idempotency_key, :stripe_account, :stripe_version]
39
+ private_constant :KNOWN_OPTS
40
+
41
+ def warn_on_opts_in_params(params)
42
+ KNOWN_OPTS.each do |opt|
43
+ if params.has_key?(opt)
44
+ $stderr.puts("WARNING: #{opt} should be in opts instead of params.")
45
+ end
46
+ end
47
+ end
33
48
  end
34
49
 
35
50
  def self.included(base)
@@ -1,3 +1,3 @@
1
1
  module Stripe
2
- VERSION = '2.10.0'
2
+ VERSION = '2.11.0'
3
3
  end
@@ -182,11 +182,37 @@ module Stripe
182
182
  Stripe::Charge.list(:count => nil, :offset => 5, :sad => false)
183
183
 
184
184
  stub_request(:post, "#{Stripe.api_base}/v1/charges").
185
- with(body: { 'amount' => '50', 'currency' => 'usd' }).
185
+ with(body: { 'amount' => '50', 'currency' => 'usd' }).
186
186
  to_return(body: JSON.generate({ :count => 1, :data => [API_FIXTURES.fetch(:charge)] }))
187
187
  Stripe::Charge.create(:amount => 50, :currency => 'usd', :card => { :number => nil })
188
188
  end
189
189
 
190
+ should "not trigger a warning if a known opt, such as idempotency_key, is in opts" do
191
+ stub_request(:post, "#{Stripe.api_base}/v1/charges").
192
+ to_return(body: JSON.generate(API_FIXTURES.fetch(:charge)))
193
+ old_stderr = $stderr
194
+ $stderr = StringIO.new
195
+ begin
196
+ Stripe::Charge.create({ :amount => 100, :currency => 'usd', :card => 'sc_token' }, { :idempotency_key => '12345' })
197
+ assert $stderr.string.empty?
198
+ ensure
199
+ $stderr = old_stderr
200
+ end
201
+ end
202
+
203
+ should "trigger a warning if a known opt, such as idempotency_key, is in params" do
204
+ stub_request(:post, "#{Stripe.api_base}/v1/charges").
205
+ to_return(body: JSON.generate(API_FIXTURES.fetch(:charge)))
206
+ old_stderr = $stderr
207
+ $stderr = StringIO.new
208
+ begin
209
+ Stripe::Charge.create({ :amount => 100, :currency => 'usd', :card => 'sc_token', :idempotency_key => '12345' })
210
+ assert_match Regexp.new('WARNING:'), $stderr.string
211
+ ensure
212
+ $stderr = old_stderr
213
+ end
214
+ end
215
+
190
216
  should "requesting with a unicode ID should result in a request" do
191
217
  stub_request(:get, "#{Stripe.api_base}/v1/customers/%E2%98%83").
192
218
  to_return(body: JSON.generate(make_missing_id_error), status: 404)
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: 2.10.0
4
+ version: 2.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-25 00:00:00.000000000 Z
11
+ date: 2017-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday