diff options
author | Robert Schilling <rschilling@student.tugraz.at> | 2014-07-27 21:56:33 +0400 |
---|---|---|
committer | Robert Schilling <rschilling@student.tugraz.at> | 2014-09-03 15:08:36 +0400 |
commit | 392113919adc75ba1537d89a0de8d0641e24d5b8 (patch) | |
tree | 79c4e5a802592024b3d6621afe4c052bea77ad4e /spec/requests/api/repositories_spec.rb | |
parent | 551145bc98e257280b615e305d531a44d7aa4131 (diff) |
Validate tag-names and references in WebUI, API
Diffstat (limited to 'spec/requests/api/repositories_spec.rb')
-rw-r--r-- | spec/requests/api/repositories_spec.rb | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/spec/requests/api/repositories_spec.rb b/spec/requests/api/repositories_spec.rb index f8603e11a04..ffcdbc4255e 100644 --- a/spec/requests/api/repositories_spec.rb +++ b/spec/requests/api/repositories_spec.rb @@ -25,20 +25,46 @@ describe API::API, api: true do describe 'POST /projects/:id/repository/tags' do it 'should create a new tag' do post api("/projects/#{project.id}/repository/tags", user), - tag_name: 'v1.0.0', + tag_name: 'v2.0.0', ref: 'master' - response.status.should == 201 - json_response['name'].should == 'v1.0.0' + json_response['name'].should == 'v2.0.0' end it 'should deny for user without push access' do post api("/projects/#{project.id}/repository/tags", user2), tag_name: 'v1.0.0', ref: '621491c677087aa243f165eab467bfdfbee00be1' - response.status.should == 403 end + + it 'should return 400 if tag name is invalid' do + post api("/projects/#{project.id}/repository/tags", user), + tag_name: 'v 1.0.0', + ref: 'master' + response.status.should == 400 + json_response['message'].should == 'Tag name invalid' + end + + it 'should return 400 if tag already exists' do + post api("/projects/#{project.id}/repository/tags", user), + tag_name: 'v8.0.0', + ref: 'master' + response.status.should == 201 + post api("/projects/#{project.id}/repository/tags", user), + tag_name: 'v8.0.0', + ref: 'master' + response.status.should == 400 + json_response['message'].should == 'Tag already exists' + end + + it 'should return 400 if ref name is invalid' do + post api("/projects/#{project.id}/repository/tags", user), + tag_name: 'mytag', + ref: 'foo' + response.status.should == 400 + json_response['message'].should == 'Invalid reference name' + end end describe "GET /projects/:id/repository/tree" do |