stripe 2.0.0 → 2.0.1

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: fe6ecafb3e94d2c21da1cad428be4ac9fda47ed9
4
- data.tar.gz: d69bf4b5289a9661d3d8a9383bb4acea4cb2c0b9
3
+ metadata.gz: a6976080db5adc63ee2fff43e9989efa8cef6cc7
4
+ data.tar.gz: 389401fb74381ee49ecf96eddc8284fe89c46224
5
5
  SHA512:
6
- metadata.gz: 381878036316652650840edfa24814e60b21ce6813a9e8cc4a5e58ff000349434d7947e63e51390d962d817755e0b40b68a1370781262b982cef93aa90296879
7
- data.tar.gz: 9afa8b57e838b7a44264f302afbb2c9b62c40176dc699a17ff83fb5fe50c4c481f0cf7de3f83dd7c7ec70211dc466d5a22e290b3157cbb2ed34bc10562871bac
6
+ metadata.gz: 0b2477c896c1807860c70af296220bf5ce630bae87c445caa3805a6b195068debc2990c8eaa08799f2f5e37b064c0d3b770119a4bbf9ca1be8c34f91d948f558
7
+ data.tar.gz: 6bf766bbdb91c02f6e709b7baa355d3b7868ce1882eea0bdb186b0f45a8969a8e93e79003df9072de14cfcc26da160f014fe1a252f2e48ab7d70526cb9f4331f
@@ -1,3 +1,7 @@
1
+ === 2.0.1 2017-02-22
2
+
3
+ * Fix multipart parameter encoding to repair broken file uploads
4
+
1
5
  === 2.0.0 2017-02-14
2
6
 
3
7
  * Drop support for Ruby 1.9
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.0
1
+ 2.0.1
@@ -15,6 +15,13 @@ module Stripe
15
15
  end
16
16
 
17
17
  def self.create(params={}, opts={})
18
+ # rest-client would accept a vanilla `File` for upload, but Faraday does
19
+ # not. Support the old API by wrapping a `File` with an `UploadIO` object
20
+ # if we're given one.
21
+ if params[:file] && params[:file].is_a?(File)
22
+ params[:file] = Faraday::UploadIO.new(params[:file], nil)
23
+ end
24
+
18
25
  opts = {
19
26
  :content_type => 'multipart/form-data',
20
27
  }.merge(Util.normalize_opts(opts))
@@ -29,6 +29,7 @@ module Stripe
29
29
  # object per thread.
30
30
  Thread.current[:stripe_client_default_conn] ||= begin
31
31
  conn = Faraday.new do |c|
32
+ c.use Faraday::Request::Multipart
32
33
  c.use Faraday::Request::UrlEncoded
33
34
  c.use Faraday::Response::RaiseError
34
35
  c.adapter Faraday.default_adapter
@@ -1,3 +1,3 @@
1
1
  module Stripe
2
- VERSION = '2.0.0'
2
+ VERSION = '2.0.1'
3
3
  end
@@ -35,7 +35,11 @@ module Stripe
35
35
 
36
36
  should "be creatable" do
37
37
  stub_request(:post, "#{Stripe.uploads_base}/v1/files").
38
- to_return(body: JSON.generate(FIXTURE))
38
+ with(:headers => {
39
+ "Content-Type" => %r|\A#{Faraday::Request::Multipart.mime_type}|
40
+ }) { |request|
41
+ request.body =~ /FileUploadTest/
42
+ }.to_return(body: JSON.generate(FIXTURE))
39
43
 
40
44
  file = Stripe::FileUpload.create(
41
45
  purpose: "dispute_evidence",
@@ -43,5 +47,20 @@ module Stripe
43
47
  )
44
48
  assert file.kind_of?(Stripe::FileUpload)
45
49
  end
50
+
51
+ should "be creatable with Faraday::UploadIO" do
52
+ stub_request(:post, "#{Stripe.uploads_base}/v1/files").
53
+ with(:headers => {
54
+ "Content-Type" => %r|\A#{Faraday::Request::Multipart.mime_type}|
55
+ }) { |request|
56
+ request.body =~ /FileUploadTest/
57
+ }.to_return(body: JSON.generate(FIXTURE))
58
+
59
+ file = Stripe::FileUpload.create(
60
+ purpose: "dispute_evidence",
61
+ file: Faraday::UploadIO.new(File.new(__FILE__), nil),
62
+ )
63
+ assert file.kind_of?(Stripe::FileUpload)
64
+ end
46
65
  end
47
66
  end
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.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-14 00:00:00.000000000 Z
11
+ date: 2017-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday