Commit 4ca3f647 authored by Robert Schilling's avatar Robert Schilling

Fix labels return code

parent 27cf081e
...@@ -45,7 +45,7 @@ Parameters: ...@@ -45,7 +45,7 @@ Parameters:
It returns 200 and the newly created label, if the operation succeeds. 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 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 ## Delete a label
...@@ -58,8 +58,8 @@ DELETE /projects/:id/labels ...@@ -58,8 +58,8 @@ DELETE /projects/:id/labels
- `id` (required) - The ID of a project - `id` (required) - The ID of a project
- `name` (required) - The name of the label to be deleted - `name` (required) - The name of the label to be deleted
It returns 200 if the label successfully was deleted, 404 for wrong parameters It returns 200 if the label successfully was deleted, 400 for wrong parameters
and 400 if the label does not exist. and 404 if the label does not exist.
In case of an error, additionally an error message is returned. In case of an error, additionally an error message is returned.
## Edit an existing label ## Edit an existing label
...@@ -79,7 +79,6 @@ Parameters: ...@@ -79,7 +79,6 @@ Parameters:
- `color` (optional) - New color of the label given in 6-digit hex notation with leading '#' sign (e.g. #FFAABB) - `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. 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 the label to be updated is missing, 404 is returned.
If parameters are invalid, 405 is returned. In case of an error, In case of an error, additionally an error message is returned.
additionally an error message is returned.
...@@ -38,7 +38,7 @@ module API ...@@ -38,7 +38,7 @@ module API
if label.valid? if label.valid?
present label, with: Entities::Label present label, with: Entities::Label
else else
render_api_error!(label.errors.full_messages.join(', '), 405) render_api_error!(label.errors.full_messages.join(', '), 400)
end end
end end
...@@ -92,7 +92,7 @@ module API ...@@ -92,7 +92,7 @@ module API
if label.update(attrs) if label.update(attrs)
present label, with: Entities::Label present label, with: Entities::Label
else else
render_api_error!(label.errors.full_messages.join(', '), 405) render_api_error!(label.errors.full_messages.join(', '), 400)
end end
end end
end end
......
...@@ -42,19 +42,19 @@ describe API::API, api: true do ...@@ -42,19 +42,19 @@ describe API::API, api: true do
response.status.should == 400 response.status.should == 400
end end
it 'should return 405 for invalid color' do it 'should return 400 for invalid color' do
post api("/projects/#{project.id}/labels", user), post api("/projects/#{project.id}/labels", user),
name: 'Foo', name: 'Foo',
color: '#FFAA' color: '#FFAA'
response.status.should == 405 response.status.should == 400
json_response['message'].should == 'Color is invalid' json_response['message'].should == 'Color is invalid'
end end
it 'should return 405 for invalid name' do it 'should return 400 for invalid name' do
post api("/projects/#{project.id}/labels", user), post api("/projects/#{project.id}/labels", user),
name: '?', name: '?',
color: '#FFAABB' color: '#FFAABB'
response.status.should == 405 response.status.should == 400
json_response['message'].should == 'Title is invalid' json_response['message'].should == 'Title is invalid'
end end
...@@ -131,20 +131,20 @@ describe API::API, api: true do ...@@ -131,20 +131,20 @@ describe API::API, api: true do
response.status.should == 400 response.status.should == 400
end end
it 'should return 405 for invalid name' do it 'should return 400 for invalid name' do
put api("/projects/#{project.id}/labels", user), put api("/projects/#{project.id}/labels", user),
name: 'label1', name: 'label1',
new_name: '?', new_name: '?',
color: '#FFFFFF' color: '#FFFFFF'
response.status.should == 405 response.status.should == 400
json_response['message'].should == 'Title is invalid' json_response['message'].should == 'Title is invalid'
end end
it 'should return 405 for invalid name' do it 'should return 400 for invalid name' do
put api("/projects/#{project.id}/labels", user), put api("/projects/#{project.id}/labels", user),
name: 'label1', name: 'label1',
color: '#FF' color: '#FF'
response.status.should == 405 response.status.should == 400
json_response['message'].should == 'Color is invalid' json_response['message'].should == 'Color is invalid'
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment