diff options
author | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2014-08-18 17:16:32 +0200 |
---|---|---|
committer | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2014-08-18 17:16:32 +0200 |
commit | 6dc24e3bcfa35daa1a39d65f5eb5bc49729309a5 (patch) | |
tree | 98823f2310c6431ad9a50d29ada6a868bffd5f2b | |
parent | 2fd7d6e2efd6c0bd86c85900f8279db8ac172f3f (diff) | |
parent | 4ca3f64719f924a483b19ba921f41ac06c3b6a63 (diff) | |
download | gitlab-ce-6dc24e3bcfa35daa1a39d65f5eb5bc49729309a5.tar.gz |
Merge pull request #7527 from Razer6/api_labels_return_code
API: Fix labels return code
-rw-r--r-- | doc/api/labels.md | 11 | ||||
-rw-r--r-- | lib/api/labels.rb | 4 | ||||
-rw-r--r-- | spec/requests/api/labels_spec.rb | 16 |
3 files changed, 15 insertions, 16 deletions
diff --git a/doc/api/labels.md b/doc/api/labels.md index 95fd4e84119..de41f35d284 100644 --- a/doc/api/labels.md +++ b/doc/api/labels.md @@ -45,7 +45,7 @@ Parameters: It returns 200 and the newly created label, if the operation succeeds. If the label already exists, 409 and an error message is returned. -If label parameters are invalid, 405 and an explaining error message is returned. +If label parameters are invalid, 400 and an explaining error message is returned. ## Delete a label @@ -58,8 +58,8 @@ DELETE /projects/:id/labels - `id` (required) - The ID of a project - `name` (required) - The name of the label to be deleted -It returns 200 if the label successfully was deleted, 404 for wrong parameters -and 400 if the label does not exist. +It returns 200 if the label successfully was deleted, 400 for wrong parameters +and 404 if the label does not exist. In case of an error, additionally an error message is returned. ## Edit an existing label @@ -79,7 +79,6 @@ Parameters: - `color` (optional) - New color of the label given in 6-digit hex notation with leading '#' sign (e.g. #FFAABB) On success, this method returns 200 with the updated label. -If required parameters are missing, 400 is returned. +If required parameters are missing or parameters are invalid, 400 is returned. If the label to be updated is missing, 404 is returned. -If parameters are invalid, 405 is returned. In case of an error, -additionally an error message is returned. +In case of an error, additionally an error message is returned. diff --git a/lib/api/labels.rb b/lib/api/labels.rb index d1684b2293c..2fdf53ffec2 100644 --- a/lib/api/labels.rb +++ b/lib/api/labels.rb @@ -39,7 +39,7 @@ module API if label.valid? present label, with: Entities::Label else - render_api_error!(label.errors.full_messages.join(', '), 405) + render_api_error!(label.errors.full_messages.join(', '), 400) end end @@ -95,7 +95,7 @@ module API if label.update(attrs) present label, with: Entities::Label else - render_api_error!(label.errors.full_messages.join(', '), 405) + render_api_error!(label.errors.full_messages.join(', '), 400) end end end diff --git a/spec/requests/api/labels_spec.rb b/spec/requests/api/labels_spec.rb index b06b353333d..cd1b84c53c9 100644 --- a/spec/requests/api/labels_spec.rb +++ b/spec/requests/api/labels_spec.rb @@ -42,19 +42,19 @@ describe API::API, api: true do response.status.should == 400 end - it 'should return 405 for invalid color' do + it 'should return 400 for invalid color' do post api("/projects/#{project.id}/labels", user), name: 'Foo', color: '#FFAA' - response.status.should == 405 + response.status.should == 400 json_response['message'].should == 'Color is invalid' end - it 'should return 405 for invalid name' do + it 'should return 400 for invalid name' do post api("/projects/#{project.id}/labels", user), name: '?', color: '#FFAABB' - response.status.should == 405 + response.status.should == 400 json_response['message'].should == 'Title is invalid' end @@ -131,20 +131,20 @@ describe API::API, api: true do response.status.should == 400 end - it 'should return 405 for invalid name' do + it 'should return 400 for invalid name' do put api("/projects/#{project.id}/labels", user), name: 'label1', new_name: '?', color: '#FFFFFF' - response.status.should == 405 + response.status.should == 400 json_response['message'].should == 'Title is invalid' end - it 'should return 405 for invalid name' do + it 'should return 400 for invalid name' do put api("/projects/#{project.id}/labels", user), name: 'label1', color: '#FF' - response.status.should == 405 + response.status.should == 400 json_response['message'].should == 'Color is invalid' end end |