diff --git a/lib/code_climate/test_reporter/client.rb b/lib/code_climate/test_reporter/client.rb index d631216..fcefa96 100644 --- a/lib/code_climate/test_reporter/client.rb +++ b/lib/code_climate/test_reporter/client.rb @@ -45,10 +45,10 @@ def batch_post_results(files) end def post_results(result) - uri = URI.parse("#{host}/test_reports") + uri = URI.parse("#{host}/test_reports?repo_token=#{result[:repo_token]}") http = http_client(uri) - request = Net::HTTP::Post.new(uri.path) + request = Net::HTTP::Post.new(uri.request_uri) request["Content-Type"] = "application/json" request.body = result.to_json diff --git a/spec/lib/formatter_spec.rb b/spec/lib/formatter_spec.rb index c130a5d..4c478ab 100644 --- a/spec/lib/formatter_spec.rb +++ b/spec/lib/formatter_spec.rb @@ -91,6 +91,8 @@ module CodeClimate::TestReporter formatter.format(simplecov_result) end app.path_info.should == "/test_reports" + app.content_type.should == "application/json" + app.query_string.should == "repo_token=172754c1bf9a3c698f7770b9fb648f1ebb214425120022d0b2ffc65b97dff531" JSON.parse(app.request_body).should == expected_request end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 1c5a9de..275f948 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -23,6 +23,14 @@ def path_info def request_body @env["rack.input"].string end + + def content_type + @env["CONTENT_TYPE"] + end + + def query_string + @env["QUERY_STRING"] + end end