stripe 3.8.0 → 3.8.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: cb5911659a15e36fb6977fa722246896dcd236dc
4
- data.tar.gz: 63ddbf69f947ed2c70b6a8c136802d4abff22712
3
+ metadata.gz: e0e126dcbcb1339f0cd72cb6e61ff8bcad95d75d
4
+ data.tar.gz: 0eeb0eb4383fca37073ff0270e14effb17776c14
5
5
  SHA512:
6
- metadata.gz: 2e80711ed5f44ceedece00a4ed078eb22ea5597e553e44260042a67936e89e83e6c594700e8e88bf7bea8cd16e227c9b70b2f31d6514746bb1f99343d4d48047
7
- data.tar.gz: 7afde30a7491263b1cd909077b1fe88ab2a03abf2fb72ba0841a1caa33506fecd3a10b5da37fe2ae9ce8a5e8b59d5e00f3036265871bb98435f23f56c8d5dac0
6
+ metadata.gz: 6e0bf6d764da6d759fb89e0d69edbffd5155f777f54a83406ddc1857ad7f8c0051aa82d1fd26943065ff2e3b5740a3aa867425255dcdf9cc6bfdb2bcbdf9f64a
7
+ data.tar.gz: dbc7388a004fcb332cc7af98c438dd149fd65b142aa4071ddbc626914526629ca2cdacb0aae439d8810ee05e64c4b390cdf5534df14bcff72c638cdbdf0c2d0c
@@ -16,7 +16,7 @@ sudo: false
16
16
 
17
17
  env:
18
18
  global:
19
- - STRIPE_MOCK_VERSION=0.2.0
19
+ - STRIPE_MOCK_VERSION=0.4.0
20
20
 
21
21
  cache:
22
22
  directories:
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.8.1 - 2017-12-06
4
+ * [#611](https://github.com/stripe/stripe-ruby/pull/611) Support `Tempfile` (as well as `File`) in file uploads
5
+
3
6
  ## 3.8.0 - 2017-10-31
4
7
  * [#606](https://github.com/stripe/stripe-ruby/pull/606) Support for exchange rates APIs
5
8
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.8.0
1
+ 3.8.1
@@ -1,3 +1,5 @@
1
+ require "tempfile"
2
+
1
3
  module Stripe
2
4
  class FileUpload < APIResource
3
5
  extend Stripe::APIOperations::Create
@@ -20,7 +22,7 @@ module Stripe
20
22
  # rest-client would accept a vanilla `File` for upload, but Faraday does
21
23
  # not. Support the old API by wrapping a `File` with an `UploadIO` object
22
24
  # if we're given one.
23
- if params[:file] && params[:file].is_a?(File)
25
+ if params[:file] && [File, Tempfile].any? { |klass| params[:file].is_a?(klass) }
24
26
  params[:file] = Faraday::UploadIO.new(params[:file], nil)
25
27
  end
26
28
 
@@ -1,3 +1,3 @@
1
1
  module Stripe
2
- VERSION = "3.8.0".freeze
2
+ VERSION = "3.8.1".freeze
3
3
  end
@@ -3,24 +3,6 @@ require File.expand_path("../../test_helper", __FILE__)
3
3
  module Stripe
4
4
  class ExchangeRateTest < Test::Unit::TestCase
5
5
  should "be listable" do
6
- # TODO: remove stub once stripe-mock supports /v1/exchange_rates
7
- stub_request(:get, "#{Stripe.api_base}/v1/exchange_rates")
8
- .to_return(body: JSON.generate(
9
- object: "list",
10
- data: [
11
- {
12
- id: "eur",
13
- object: "exchange_rate",
14
- rates: { "usd" => 1.18221 },
15
- },
16
- {
17
- id: "usd",
18
- object: "exchange_rate",
19
- rates: { "eur" => 0.845876 },
20
- },
21
- ]
22
- ))
23
-
24
6
  list_rates = Stripe::ExchangeRate.list
25
7
  assert_requested :get, "#{Stripe.api_base}/v1/exchange_rates"
26
8
  assert list_rates.data.is_a?(Array)
@@ -28,14 +10,6 @@ module Stripe
28
10
  end
29
11
 
30
12
  should "be retrievable" do
31
- # TODO: remove stub once stripe-mock supports /v1/exchange_rates
32
- stub_request(:get, "#{Stripe.api_base}/v1/exchange_rates/usd")
33
- .to_return(body: JSON.generate(
34
- id: "usd",
35
- object: "exchange_rate",
36
- rates: { "eur" => 0.845876 }
37
- ))
38
-
39
13
  rates = Stripe::ExchangeRate.retrieve("usd")
40
14
  assert_requested :get, "#{Stripe.api_base}/v1/exchange_rates/usd"
41
15
  assert rates.is_a?(Stripe::ExchangeRate)
@@ -31,7 +31,7 @@ module Stripe
31
31
  assert file.is_a?(Stripe::FileUpload)
32
32
  end
33
33
 
34
- should "be creatable" do
34
+ should "be creatable with a File" do
35
35
  stub_request(:post, "#{Stripe.uploads_base}/v1/files")
36
36
  .with(headers: {
37
37
  "Content-Type" => /\A#{Faraday::Request::Multipart.mime_type}/,
@@ -46,6 +46,25 @@ module Stripe
46
46
  assert file.is_a?(Stripe::FileUpload)
47
47
  end
48
48
 
49
+ should "be creatable with a Tempfile" do
50
+ stub_request(:post, "#{Stripe.uploads_base}/v1/files")
51
+ .with(headers: {
52
+ "Content-Type" => /\A#{Faraday::Request::Multipart.mime_type}/,
53
+ }) do |request|
54
+ request.body =~ /Hello world/
55
+ end.to_return(body: JSON.generate(FIXTURE))
56
+
57
+ tempfile = Tempfile.new("foo")
58
+ tempfile.write("Hello world")
59
+ tempfile.rewind
60
+
61
+ file = Stripe::FileUpload.create(
62
+ purpose: "dispute_evidence",
63
+ file: tempfile
64
+ )
65
+ assert file.is_a?(Stripe::FileUpload)
66
+ end
67
+
49
68
  should "be creatable with Faraday::UploadIO" do
50
69
  stub_request(:post, "#{Stripe.uploads_base}/v1/files")
51
70
  .with(headers: {
@@ -10,7 +10,7 @@ PROJECT_ROOT = File.expand_path("../../", __FILE__)
10
10
 
11
11
  require File.expand_path("../test_data", __FILE__)
12
12
 
13
- MOCK_MINIMUM_VERSION = "0.2.0".freeze
13
+ MOCK_MINIMUM_VERSION = "0.4.0".freeze
14
14
  MOCK_PORT = ENV["STRIPE_MOCK_PORT"] || 12_111
15
15
 
16
16
  # Disable all real network connections except those that are outgoing to
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: 3.8.0
4
+ version: 3.8.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-10-31 00:00:00.000000000 Z
11
+ date: 2017-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday