diff options
author | jubianchi <contact@jubianchi.fr> | 2014-08-18 20:09:09 +0200 |
---|---|---|
committer | jubianchi <contact@jubianchi.fr> | 2014-09-16 01:25:24 +0200 |
commit | 998cd3cb63d56a0058c8e519d7c20e3d6e540899 (patch) | |
tree | 38b9319858451f8bbebc7670e5505a7f1e6665e1 /spec/requests/api/labels_spec.rb | |
parent | 892371bc22813abe855f563bf4f0ee355fe067ab (diff) | |
download | gitlab-ce-998cd3cb63d56a0058c8e519d7c20e3d6e540899.tar.gz |
Improve error reporting on users API
* users (#6878, #3526, #4209): Validation error messages are now exposed through 400 responses, 409 response are sent in case of duplicate email or username
* MRs (#5335): 409 responses are sent in case of duplicate merge request (source/target branches), 422 responses are sent when submiting MR fo/from unrelated forks
* issues
* labels
* projects
Diffstat (limited to 'spec/requests/api/labels_spec.rb')
-rw-r--r-- | spec/requests/api/labels_spec.rb | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/spec/requests/api/labels_spec.rb b/spec/requests/api/labels_spec.rb index ee9088933a1..dbddc8a7da4 100644 --- a/spec/requests/api/labels_spec.rb +++ b/spec/requests/api/labels_spec.rb @@ -47,7 +47,7 @@ describe API::API, api: true do name: 'Foo', color: '#FFAA' response.status.should == 400 - json_response['message'].should == 'Color is invalid' + json_response['message']['color'].should == ['is invalid'] end it 'should return 400 for too long color code' do @@ -55,7 +55,7 @@ describe API::API, api: true do name: 'Foo', color: '#FFAAFFFF' response.status.should == 400 - json_response['message'].should == 'Color is invalid' + json_response['message']['color'].should == ['is invalid'] end it 'should return 400 for invalid name' do @@ -63,7 +63,7 @@ describe API::API, api: true do name: '?', color: '#FFAABB' response.status.should == 400 - json_response['message'].should == 'Title is invalid' + json_response['message']['title'].should == ['is invalid'] end it 'should return 409 if label already exists' do @@ -84,7 +84,7 @@ describe API::API, api: true do it 'should return 404 for non existing label' do delete api("/projects/#{project.id}/labels", user), name: 'label2' response.status.should == 404 - json_response['message'].should == 'Label not found' + json_response['message'].should == '404 Label Not Found' end it 'should return 400 for wrong parameters' do @@ -132,11 +132,14 @@ describe API::API, api: true do it 'should return 400 if no label name given' do put api("/projects/#{project.id}/labels", user), new_name: 'label2' response.status.should == 400 + json_response['message'].should == '400 (Bad request) "name" not given' end it 'should return 400 if no new parameters given' do put api("/projects/#{project.id}/labels", user), name: 'label1' response.status.should == 400 + json_response['message'].should == 'Required parameters '\ + '"new_name" or "color" missing' end it 'should return 400 for invalid name' do @@ -145,7 +148,7 @@ describe API::API, api: true do new_name: '?', color: '#FFFFFF' response.status.should == 400 - json_response['message'].should == 'Title is invalid' + json_response['message']['title'].should == ['is invalid'] end it 'should return 400 for invalid name' do @@ -153,7 +156,7 @@ describe API::API, api: true do name: 'label1', color: '#FF' response.status.should == 400 - json_response['message'].should == 'Color is invalid' + json_response['message']['color'].should == ['is invalid'] end it 'should return 400 for too long color code' do @@ -161,7 +164,7 @@ describe API::API, api: true do name: 'Foo', color: '#FFAAFFFF' response.status.should == 400 - json_response['message'].should == 'Color is invalid' + json_response['message']['color'].should == ['is invalid'] end end end |