@@ -33,6 +33,7 @@ def request_body(method, url)
33
33
34
34
proxy . stub ( "https://api.github.com:443/repos/jtarchie/test/statuses/#{ @sha } " )
35
35
. and_return ( json : [ ] )
36
+ ENV [ 'BUILD_ID' ] = '1234'
36
37
end
37
38
38
39
context 'when the git repo has no pull request meta information' do
@@ -108,8 +109,21 @@ def request_body(method, url)
108
109
proxy . stub ( "https://api.github.com:443/repos/jtarchie/test/statuses/#{ @sha } " , method : :post )
109
110
110
111
put ( params : { status : 'success' , path : 'resource' } , source : { repo : 'jtarchie/test' , base_url : 'http://example.com' } )
112
+
113
+ body = request_body ( 'post' , "https://api.github.com:443/repos/jtarchie/test/statuses/#{ @sha } " )
114
+ expect ( JSON . parse ( body ) ) . to include ( 'target_url' => 'http://example.com/builds/1234' )
115
+ end
116
+ end
117
+
118
+ context 'with no base_url defined, but with ATC_EXTERNAL_URL defined' do
119
+ it 'sets the target_url for status' do
120
+ ENV [ 'ATC_EXTERNAL_URL' ] = 'http://atc-endpoint.com'
121
+ proxy . stub ( "https://api.github.com:443/repos/jtarchie/test/statuses/#{ @sha } " , method : :post )
122
+
123
+ put ( params : { status : 'success' , path : 'resource' } , source : { repo : 'jtarchie/test' } )
124
+
111
125
body = request_body ( 'post' , "https://api.github.com:443/repos/jtarchie/test/statuses/#{ @sha } " )
112
- expect ( JSON . parse ( body ) ) . to include ( 'target_url' => 'http://example .com/builds/' )
126
+ expect ( JSON . parse ( body ) ) . to include ( 'target_url' => 'http://atc-endpoint .com/builds/1234 ' )
113
127
end
114
128
end
115
129
end
0 commit comments