Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/intercom/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def parse_body(decoded_body, response)
rescue JSON::ParserError => _
raise_errors_on_failure(response)
end
raise_application_errors_on_failure(parsed_body, response.code.to_i) if parsed_body['type'] == 'error.list'
raise_application_errors_on_failure(parsed_body, response.code.to_i) if parsed_body&['type'] == 'error.list'
parsed_body
end

Expand Down
6 changes: 6 additions & 0 deletions spec/unit/intercom/request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,10 @@
req = Intercom::Request.new('path/', 'GET')
req.parse_body(nil, response).must_equal(nil)
end

it 'parse_body returns nil if the decoded_body is "null"' do
response = OpenStruct.new(:code => 500)
req = Intercom::Request.new('path/', 'GET')
req.parse_body('null', response).must_equal(nil)
end
end