diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2017-01-19 11:37:38 +0000 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2017-01-19 11:37:38 +0000 |
commit | 046e0bd6e73d4da2624389bd93a6536b784c926b (patch) | |
tree | ad21f1cb3b7426c93a88774b0d0b0acfb9beccca /spec/requests | |
parent | b71b0acd55e773fd79e0c54e98b53561a6657249 (diff) | |
parent | 9ce8aa31f2f55563cbf4212f7dd2b51576967a55 (diff) | |
download | gitlab-ce-046e0bd6e73d4da2624389bd93a6536b784c926b.tar.gz |
Merge branch 'fix/external-status-badge-links' into 'master'
Link external commit status badges to target URLs
Closes #25662
See merge request !8611
Diffstat (limited to 'spec/requests')
-rw-r--r-- | spec/requests/api/commit_statuses_spec.rb | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/spec/requests/api/commit_statuses_spec.rb b/spec/requests/api/commit_statuses_spec.rb index 335efc4db6c..c1c7c0882de 100644 --- a/spec/requests/api/commit_statuses_spec.rb +++ b/spec/requests/api/commit_statuses_spec.rb @@ -152,8 +152,11 @@ describe API::CommitStatuses, api: true do context 'with all optional parameters' do before do - optional_params = { state: 'success', context: 'coverage', - ref: 'develop', target_url: 'url', description: 'test' } + optional_params = { state: 'success', + context: 'coverage', + ref: 'develop', + description: 'test', + target_url: 'http://gitlab.com/status' } post api(post_url, developer), optional_params end @@ -164,12 +167,12 @@ describe API::CommitStatuses, api: true do expect(json_response['status']).to eq('success') expect(json_response['name']).to eq('coverage') expect(json_response['ref']).to eq('develop') - expect(json_response['target_url']).to eq('url') expect(json_response['description']).to eq('test') + expect(json_response['target_url']).to eq('http://gitlab.com/status') end end - context 'invalid status' do + context 'when status is invalid' do before { post api(post_url, developer), state: 'invalid' } it 'does not create commit status' do @@ -177,7 +180,7 @@ describe API::CommitStatuses, api: true do end end - context 'request without state' do + context 'when request without a state made' do before { post api(post_url, developer) } it 'does not create commit status' do @@ -185,7 +188,7 @@ describe API::CommitStatuses, api: true do end end - context 'invalid commit' do + context 'when commit SHA is invalid' do let(:sha) { 'invalid_sha' } before { post api(post_url, developer), state: 'running' } @@ -193,6 +196,19 @@ describe API::CommitStatuses, api: true do expect(response).to have_http_status(404) end end + + context 'when target URL is an invalid address' do + before do + post api(post_url, developer), state: 'pending', + target_url: 'invalid url' + end + + it 'responds with bad request status and validation errors' do + expect(response).to have_http_status(400) + expect(json_response['message']['target_url']) + .to include 'must be a valid URL' + end + end end context 'reporter user' do |