Skip to content
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

Commit ad97e4c

Browse files
author
Jon Yurek
committed
Do not use #to_json on HipChat's params
1 parent 26312cc commit ad97e4c

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

lib/cc/services/hipchat.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def speak(message, color)
5151
notify: !!config.notify,
5252
color: color
5353
}
54-
post(url, params.to_json)
54+
post(url, params)
5555
end
5656

5757
end

test/flowdock_test.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
class TestFlowdock < CC::Service::TestCase
44
def test_valid_project_parameter
55
@stubs.post '/v1/messages/team_inbox/token' do |env|
6-
body = env[:body]
7-
assert_equal "Exampleorg", body[:project]
6+
body = Hash[URI.decode_www_form(env[:body])]
7+
assert_equal "Exampleorg", body["project"]
88
[200, {}, '']
99
end
1010

@@ -127,15 +127,15 @@ def token
127127

128128
def assert_flowdock_receives(subject, event_data, expected_body)
129129
@stubs.post request_url do |env|
130-
body = env[:body]
131-
assert_equal "Code Climate", body[:source]
132-
assert_equal "[email protected]", body[:from_address]
133-
assert_equal "Code Climate", body[:from_name]
134-
assert_equal "html", body[:format]
135-
assert_equal subject, body[:subject]
136-
assert_equal "Example", body[:project]
137-
assert_equal expected_body, body[:content]
138-
assert_equal "https://codeclimate.com", body[:link]
130+
body = Hash[URI.decode_www_form(env[:body])]
131+
assert_equal "Code Climate", body["source"]
132+
assert_equal "[email protected]", body["from_address"]
133+
assert_equal "Code Climate", body["from_name"]
134+
assert_equal "html", body["format"]
135+
assert_equal subject, body["subject"]
136+
assert_equal "Example", body["project"]
137+
assert_equal expected_body, body["content"]
138+
assert_equal "https://codeclimate.com", body["link"]
139139
[200, {}, '']
140140
end
141141

test/hipchat_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ def test_receive_test
108108

109109
def assert_hipchat_receives(color, event_data, expected_body)
110110
@stubs.post '/v1/rooms/message' do |env|
111-
body = JSON.parse(env[:body])
111+
body = Hash[URI.decode_www_form(env[:body])]
112112
assert_equal "token", body["auth_token"]
113113
assert_equal "123", body["room_id"]
114-
assert_equal true, body["notify"]
114+
assert_equal "true", body["notify"]
115115
assert_equal color, body["color"]
116116
assert_equal expected_body, body["message"]
117117
[200, {}, '']

0 commit comments

Comments
 (0)