Skip to content

Commit baefc46

Browse files
committed
Add test for merge commit detection.
1 parent f83ef3b commit baefc46

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

spec/commands/out_spec.rb

+17
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,23 @@ def stub_json(method, uri, body)
303303
{ 'name' => 'url', 'value' => 'http://example.com' }
304304
])
305305
end
306+
context 'when fetching a merged commit' do
307+
it 'posts the status to the PR\'s SHA instead of the merge SHA.' do
308+
stub_json(:get, 'https://api.github.com:443/repos/jtarchie/test/pulls/1',
309+
html_url: 'http://example.com',
310+
number: 1,
311+
head: { sha: 'abcdef' },
312+
merge_commit_sha: @sha)
313+
stub_request(:post, 'https://api.github.com:443/repos/jtarchie/test/statuses/abcdef')
314+
output, = put('params' => { 'status' => 'failure', 'path' => 'resource' }, 'source' => { 'repo' => 'jtarchie/test' })
315+
expect(output).to eq('version' => { 'ref' => 'abcdef', 'pr' => '1' },
316+
'metadata' => [
317+
{ 'name' => 'status', 'value' => 'failure' },
318+
{ 'name' => 'url', 'value' => 'http://example.com' }
319+
])
320+
321+
end
322+
end
306323
end
307324
end
308325
end

0 commit comments

Comments
 (0)