File tree Expand file tree Collapse file tree 3 files changed +8
-0
lines changed
lib/code_climate/test_reporter Expand file tree Collapse file tree 3 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ module TestReporter
8
8
class Client
9
9
10
10
DEFAULT_TIMEOUT = 5 # in seconds
11
+ USER_AGENT = "Code Climate (Ruby Test Reporter v#{ VERSION } )"
11
12
12
13
def host
13
14
ENV [ "CODECLIMATE_API_HOST" ] ||
@@ -33,6 +34,7 @@ def batch_post_results(files)
33
34
end
34
35
post_body << "\r \n --#{ boundary } --\r \n "
35
36
request = Net ::HTTP ::Post . new ( uri . request_uri )
37
+ request [ "User-Agent" ] = USER_AGENT
36
38
request . body = post_body . join
37
39
request [ "Content-Type" ] = "multipart/form-data, boundary=#{ boundary } "
38
40
response = http . request ( request )
@@ -49,6 +51,7 @@ def post_results(result)
49
51
http = http_client ( uri )
50
52
51
53
request = Net ::HTTP ::Post . new ( uri . path )
54
+ request [ "User-Agent" ] = USER_AGENT
52
55
request [ "Content-Type" ] = "application/json"
53
56
request [ "Content-Encoding" ] = "gzip"
54
57
request . body = compress ( result . to_json )
Original file line number Diff line number Diff line change @@ -95,6 +95,7 @@ module CodeClimate::TestReporter
95
95
app . http_content_encoding . should == "gzip"
96
96
uncompressed = inflate ( app . request_body )
97
97
JSON . parse ( uncompressed ) . should == expected_request
98
+ app . http_user_agent . should include ( "v#{ CodeClimate ::TestReporter ::VERSION } " )
98
99
end
99
100
end
100
101
end
Original file line number Diff line number Diff line change @@ -37,6 +37,10 @@ def content_type
37
37
def http_content_encoding
38
38
@env [ "HTTP_CONTENT_ENCODING" ]
39
39
end
40
+
41
+ def http_user_agent
42
+ @env [ "HTTP_USER_AGENT" ]
43
+ end
40
44
end
41
45
42
46
You can’t perform that action at this time.
0 commit comments