heroku-api 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
+ 0.4.2 03/02/2016
2
+ ================
3
+ Rethrow json parsing errors when application/json
4
+
1
5
  0.4.1 02/05/2016
2
6
  ================
3
7
  Move login parameters from query to post body
@@ -112,6 +112,9 @@ module Heroku
112
112
  begin
113
113
  response.body = MultiJson.load(response.body)
114
114
  rescue
115
+ if response.headers['Content-Type'] === 'application/json'
116
+ raise
117
+ end
115
118
  # leave non-JSON body as is
116
119
  end
117
120
  end
@@ -1,5 +1,5 @@
1
1
  module Heroku
2
2
  class API
3
- VERSION = "0.4.1"
3
+ VERSION = "0.4.2"
4
4
  end
5
5
  end
@@ -0,0 +1,37 @@
1
+ require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
2
+
3
+ class TestApi < Minitest::Test
4
+
5
+ def test_json_parsing_failure_for_application_json
6
+ Excon.stub(:expects => 200, :method => :get, :path => "/foobar") do |params|
7
+ {
8
+ :body => "string",
9
+ :status => 200,
10
+ :headers => {'Content-Type' => 'application/json'}
11
+ }
12
+ end
13
+
14
+ begin
15
+ heroku.request(:expects => 200, :method => :get, :path => "/foobar")
16
+ fail("Expected MultiJson::ParseError")
17
+ rescue MultiJson::ParseError
18
+ # should raise parse error
19
+ end
20
+ end
21
+
22
+ def test_json_parsing_failure_for_text_plain
23
+ Excon.stub(:expects => 200, :method => :get, :path => "/foobar") do |params|
24
+ {
25
+ :body => "string",
26
+ :status => 200,
27
+ :headers => {'Content-Type' => 'text/plain'}
28
+ }
29
+ end
30
+
31
+ response = heroku.request(:expects => 200, :method => :get, :path => "/foobar")
32
+
33
+ assert_equal(200, response.status)
34
+ assert_equal("string", response.body)
35
+ end
36
+
37
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroku-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-02-05 00:00:00.000000000 Z
13
+ date: 2016-03-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: excon
@@ -133,6 +133,7 @@ files:
133
133
  - test/data/site.crt
134
134
  - test/data/site.key
135
135
  - test/test_addons.rb
136
+ - test/test_api.rb
136
137
  - test/test_apps.rb
137
138
  - test/test_attachments.rb
138
139
  - test/test_buildpacks.rb
@@ -180,6 +181,7 @@ test_files:
180
181
  - test/data/site.crt
181
182
  - test/data/site.key
182
183
  - test/test_addons.rb
184
+ - test/test_api.rb
183
185
  - test/test_apps.rb
184
186
  - test/test_attachments.rb
185
187
  - test/test_buildpacks.rb