Skip to content

Commit b6bc91a

Browse files
committed
Merge pull request #66 from intercom/strip-blank-responses
don't parse blank responses as json
2 parents 7b27d24 + a665cdf commit b6bc91a

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

lib/intercom/request.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def execute(target_base_url=nil)
6262
response = http.request(net_http_method)
6363
raise_errors_on_failure(response)
6464
decoded = decode(response['content-encoding'], response.body)
65-
JSON.parse(decoded) unless decoded.empty?
65+
JSON.parse(decoded) unless decoded.strip.empty?
6666
end
6767
rescue Timeout::Error
6868
raise Intercom::ServiceUnavailableError

lib/intercom/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Intercom #:nodoc:
2-
VERSION = "0.2.2"
2+
VERSION = "0.2.3"
33
end

spec/integration/intercom_api_integration_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ def fixture(name)
4848
message_thread.send(expected).wont_be_nil
4949
end
5050
end
51+
52+
it "handles blank string bodies" do
53+
FakeWeb.register_uri(:get, %r(v1/users\?email=), :body => fixture('v1-user'))
54+
user = Intercom::User.find(:email => "[email protected]")
55+
FakeWeb.register_uri(:post, %r(/events), :status => ["202", "Created"], :body => ' ')
56+
end
5157

5258
it "should mark message_thread as read" do
5359
FakeWeb.register_uri(:get, %r(v1/users/message_threads\?email=somebody), :body => fixture('v1-users-message_threads'))

0 commit comments

Comments
 (0)