Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Schilling <rschilling@student.tugraz.at>2014-08-12 16:16:25 +0400
committerRobert Schilling <rschilling@student.tugraz.at>2014-08-13 14:28:19 +0400
commit9284038dbef5153dac40eda14f1685a72efe1d1a (patch)
tree1b195e94518f115316da6f98195943dc8d22c2c0 /spec/requests/api/labels_spec.rb
parent53ead2e35c9195ae1f68bf5d7154e341636caf1b (diff)
Add, delete labels via API
Diffstat (limited to 'spec/requests/api/labels_spec.rb')
-rw-r--r--spec/requests/api/labels_spec.rb65
1 files changed, 65 insertions, 0 deletions
diff --git a/spec/requests/api/labels_spec.rb b/spec/requests/api/labels_spec.rb
index d40c2c21cec..6a633e666b3 100644
--- a/spec/requests/api/labels_spec.rb
+++ b/spec/requests/api/labels_spec.rb
@@ -21,4 +21,69 @@ describe API::API, api: true do
json_response.first['name'].should == label1.name
end
end
+
+ describe 'POST /projects/:id/labels' do
+ it 'should return created label' do
+ post api("/projects/#{project.id}/labels", user),
+ name: 'Foo',
+ color: '#FFAABB'
+ response.status.should == 201
+ json_response['name'].should == 'Foo'
+ json_response['color'].should == '#FFAABB'
+ end
+
+ it 'should return a 400 bad request if name not given' do
+ post api("/projects/#{project.id}/labels", user), color: '#FFAABB'
+ response.status.should == 400
+ end
+
+ it 'should return a 400 bad request if color not given' do
+ post api("/projects/#{project.id}/labels", user), name: 'Foobar'
+ response.status.should == 400
+ end
+
+ it 'should return 405 for invalid color' do
+ post api("/projects/#{project.id}/labels", user),
+ name: 'Foo',
+ color: '#FFAA'
+ response.status.should == 405
+ json_response['message'].should == 'Color is invalid'
+ end
+
+ it 'should return 405 for invalid name' do
+ post api("/projects/#{project.id}/labels", user),
+ name: '?',
+ color: '#FFAABB'
+ response.status.should == 405
+ json_response['message'].should == 'Title is invalid'
+ end
+
+ it 'should return 409 if label already exists' do
+ post api("/projects/#{project.id}/labels", user),
+ name: 'label1',
+ color: '#FFAABB'
+ response.status.should == 409
+ json_response['message'].should == 'Label already exists'
+ end
+ end
+
+ describe 'DELETE /projects/:id/labels' do
+ it 'should return 200 for existing label' do
+ delete api("/projects/#{project.id}/labels", user),
+ name: 'label1'
+ response.status.should == 200
+ end
+
+ 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'
+ end
+
+ it 'should return 400 for wrong parameters' do
+ delete api("/projects/#{project.id}/labels", user)
+ response.status.should == 400
+ end
+ end
end