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:
authorJames Edwards-Jones <jedwardsjones@gitlab.com>2018-03-25 03:54:56 +0300
committerJames Edwards-Jones <jedwardsjones@gitlab.com>2018-03-26 12:29:52 +0300
commit973bd4622dec2c326d05a047b93a7b67c9196fb4 (patch)
tree4e87541b35859580eb32869f358b6b52b4201f8f /spec/services/protected_branches/update_service_spec.rb
parente7061396666074c799780a9fc4090267c3b87e12 (diff)
ProtectedBranchPolicy used from Controller for destroy/update
Diffstat (limited to 'spec/services/protected_branches/update_service_spec.rb')
-rw-r--r--spec/services/protected_branches/update_service_spec.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/spec/services/protected_branches/update_service_spec.rb b/spec/services/protected_branches/update_service_spec.rb
index 9fa5983db66..3f6f8e09565 100644
--- a/spec/services/protected_branches/update_service_spec.rb
+++ b/spec/services/protected_branches/update_service_spec.rb
@@ -22,5 +22,16 @@ describe ProtectedBranches::UpdateService do
expect { service.execute(protected_branch) }.to raise_error(Gitlab::Access::AccessDeniedError)
end
end
+
+ context 'when a policy restricts rule creation' do
+ before do
+ policy = instance_double(ProtectedBranchPolicy, can?: false)
+ expect(ProtectedBranchPolicy).to receive(:new).and_return(policy)
+ end
+
+ it "prevents creation of the protected branch rule" do
+ expect { service.execute(protected_branch) }.to raise_error(Gitlab::Access::AccessDeniedError)
+ end
+ end
end
end