diff options
author | Sam Rose <samrose3@gmail.com> | 2017-05-08 07:41:58 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-05-08 07:41:58 +0000 |
commit | 1ebd9dad8e4a3ade4fa829d1d5ac6cbc9825bf48 (patch) | |
tree | ea175b4ef388f79d8550a424ac5b46a535555664 /spec/lib/gitlab/user_access_spec.rb | |
parent | 1a5e84febeb3f2d63c019981e80c777195c37dd2 (diff) | |
download | gitlab-ce-1ebd9dad8e4a3ade4fa829d1d5ac6cbc9825bf48.tar.gz |
Add confirm delete protected branch modal
Diffstat (limited to 'spec/lib/gitlab/user_access_spec.rb')
-rw-r--r-- | spec/lib/gitlab/user_access_spec.rb | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/spec/lib/gitlab/user_access_spec.rb b/spec/lib/gitlab/user_access_spec.rb index 2b27ff66c09..0d87cf25dbb 100644 --- a/spec/lib/gitlab/user_access_spec.rb +++ b/spec/lib/gitlab/user_access_spec.rb @@ -5,7 +5,7 @@ describe Gitlab::UserAccess, lib: true do let(:project) { create(:project) } let(:user) { create(:user) } - describe 'can_push_to_branch?' do + describe '#can_push_to_branch?' do describe 'push to none protected branch' do it 'returns true if user is a master' do project.team << [user, :master] @@ -143,7 +143,7 @@ describe Gitlab::UserAccess, lib: true do end end - describe 'can_create_tag?' do + describe '#can_create_tag?' do describe 'push to none protected tag' do it 'returns true if user is a master' do project.add_user(user, :master) @@ -211,4 +211,48 @@ describe Gitlab::UserAccess, lib: true do end end end + + describe '#can_delete_branch?' do + describe 'delete unprotected branch' do + it 'returns true if user is a master' do + project.add_user(user, :master) + + expect(access.can_delete_branch?('random_branch')).to be_truthy + end + + it 'returns true if user is a developer' do + project.add_user(user, :developer) + + expect(access.can_delete_branch?('random_branch')).to be_truthy + end + + it 'returns false if user is a reporter' do + project.add_user(user, :reporter) + + expect(access.can_delete_branch?('random_branch')).to be_falsey + end + end + + describe 'delete protected branch' do + let(:branch) { create(:protected_branch, project: project, name: "test") } + + it 'returns true if user is a master' do + project.add_user(user, :master) + + expect(access.can_delete_branch?(branch.name)).to be_truthy + end + + it 'returns false if user is a developer' do + project.add_user(user, :developer) + + expect(access.can_delete_branch?(branch.name)).to be_falsey + end + + it 'returns false if user is a reporter' do + project.add_user(user, :reporter) + + expect(access.can_delete_branch?(branch.name)).to be_falsey + end + end + end end |