summaryrefslogtreecommitdiff
path: root/spec/services/protected_branches
diff options
context:
space:
mode:
authorTiago Botelho <tiagonbotelho@hotmail.com>2018-01-03 16:01:46 +0000
committerTiago Botelho <tiagonbotelho@hotmail.com>2018-01-06 12:20:49 +0000
commit819fc98fed227487b0a273ee294e374e7457782b (patch)
tree9d8f3641fed389584f924b3698365e1d821cfd80 /spec/services/protected_branches
parent1e950e3148d31cb3b242cb21be11e04964c2a037 (diff)
downloadgitlab-ce-819fc98fed227487b0a273ee294e374e7457782b.tar.gz
Protected branch is now created for default branch on import3968-protected-branch-is-not-set-for-default-branch-on-import
Diffstat (limited to 'spec/services/protected_branches')
-rw-r--r--spec/services/protected_branches/create_service_spec.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/services/protected_branches/create_service_spec.rb b/spec/services/protected_branches/create_service_spec.rb
index 835e83d6dba..53b3e5e365d 100644
--- a/spec/services/protected_branches/create_service_spec.rb
+++ b/spec/services/protected_branches/create_service_spec.rb
@@ -19,5 +19,21 @@ describe ProtectedBranches::CreateService do
expect(project.protected_branches.last.push_access_levels.map(&:access_level)).to eq([Gitlab::Access::MASTER])
expect(project.protected_branches.last.merge_access_levels.map(&:access_level)).to eq([Gitlab::Access::MASTER])
end
+
+ context 'when user does not have permission' do
+ let(:user) { create(:user) }
+
+ before do
+ project.add_developer(user)
+ end
+
+ it 'creates a new protected branch if we skip authorization step' do
+ expect { service.execute(skip_authorization: true) }.to change(ProtectedBranch, :count).by(1)
+ end
+
+ it 'raises Gitlab::Access:AccessDeniedError' do
+ expect { service.execute }.to raise_error(Gitlab::Access::AccessDeniedError)
+ end
+ end
end
end