diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-01-18 14:24:53 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-01-18 14:30:01 +0300 |
commit | 9ce8aa31f2f55563cbf4212f7dd2b51576967a55 (patch) | |
tree | 256f5f0a00ec166e3d71ef11e9e0e57bd072906d /spec/requests/api/commit_statuses_spec.rb | |
parent | 53f4f849956e10ccbbf4a9011b46b84da33129b0 (diff) |
Respond with validation errors in commit status API
If validation errors are present, include validation errors in the
commit status API payload, instead of depending on state machine errors
caused by invalid record.
Diffstat (limited to 'spec/requests/api/commit_statuses_spec.rb')
-rw-r--r-- | spec/requests/api/commit_statuses_spec.rb | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/spec/requests/api/commit_statuses_spec.rb b/spec/requests/api/commit_statuses_spec.rb index ffd38ff303a..c1c7c0882de 100644 --- a/spec/requests/api/commit_statuses_spec.rb +++ b/spec/requests/api/commit_statuses_spec.rb @@ -172,7 +172,7 @@ describe API::CommitStatuses, api: true do 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 @@ -180,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 @@ -188,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' } @@ -196,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 |