diff options
author | Robert Schilling <rschilling@student.tugraz.at> | 2014-08-13 14:23:51 +0400 |
---|---|---|
committer | Robert Schilling <rschilling@student.tugraz.at> | 2014-08-13 14:29:03 +0400 |
commit | cf3ba0209dc7dc8b9ac93d574a8f6296b858be40 (patch) | |
tree | 07fa92aa498deb4866ba6f75ed2e9cf03e1a2df6 /spec/requests/api/labels_spec.rb | |
parent | 9284038dbef5153dac40eda14f1685a72efe1d1a (diff) |
Update labels via API
Diffstat (limited to 'spec/requests/api/labels_spec.rb')
-rw-r--r-- | spec/requests/api/labels_spec.rb | 70 |
1 files changed, 66 insertions, 4 deletions
diff --git a/spec/requests/api/labels_spec.rb b/spec/requests/api/labels_spec.rb index 6a633e666b3..b06b353333d 100644 --- a/spec/requests/api/labels_spec.rb +++ b/spec/requests/api/labels_spec.rb @@ -69,14 +69,12 @@ describe API::API, api: true do describe 'DELETE /projects/:id/labels' do it 'should return 200 for existing label' do - delete api("/projects/#{project.id}/labels", user), - name: 'label1' + 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' + delete api("/projects/#{project.id}/labels", user), name: 'label2' response.status.should == 404 json_response['message'].should == 'Label not found' end @@ -86,4 +84,68 @@ describe API::API, api: true do response.status.should == 400 end end + + describe 'PUT /projects/:id/labels' do + it 'should return 200 if name and colors are changed' do + put api("/projects/#{project.id}/labels", user), + name: 'label1', + new_name: 'New Label', + color: '#FFFFFF' + response.status.should == 200 + json_response['name'].should == 'New Label' + json_response['color'].should == '#FFFFFF' + end + + it 'should return 200 if name is changed' do + put api("/projects/#{project.id}/labels", user), + name: 'label1', + new_name: 'New Label' + response.status.should == 200 + json_response['name'].should == 'New Label' + json_response['color'].should == label1.color + end + + it 'should return 200 if colors is changed' do + put api("/projects/#{project.id}/labels", user), + name: 'label1', + color: '#FFFFFF' + response.status.should == 200 + json_response['name'].should == label1.name + json_response['color'].should == '#FFFFFF' + end + + it 'should return 404 if label does not exist' do + put api("/projects/#{project.id}/labels", user), + name: 'label2', + new_name: 'label3' + response.status.should == 404 + end + + it 'should return 400 if no label name given' do + put api("/projects/#{project.id}/labels", user), new_name: 'label2' + response.status.should == 400 + end + + it 'should return 400 if no new parameters given' do + put api("/projects/#{project.id}/labels", user), name: 'label1' + response.status.should == 400 + end + + it 'should return 405 for invalid name' do + put api("/projects/#{project.id}/labels", user), + name: 'label1', + new_name: '?', + color: '#FFFFFF' + response.status.should == 405 + json_response['message'].should == 'Title is invalid' + end + + it 'should return 405 for invalid name' do + put api("/projects/#{project.id}/labels", user), + name: 'label1', + color: '#FF' + response.status.should == 405 + json_response['message'].should == 'Color is invalid' + end + end end |