diff options
author | Rémy Coutable <remy@rymai.me> | 2017-02-23 18:14:33 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-02-23 18:14:33 +0000 |
commit | 6904814ba3da6db3047f19a5d2058deea3cc3bbf (patch) | |
tree | 0e1b15ba053e5f889cb49ba2534ae5a2b1c3fff6 /spec/lib | |
parent | 62829b6bd885ef09d2060d1230c5b5c4a1e62eb1 (diff) | |
parent | 485ac92244d75403ab6238278595d9bc15e254bb (diff) | |
download | gitlab-ce-6904814ba3da6db3047f19a5d2058deea3cc3bbf.tar.gz |
Merge branch 'fix-git-access-specs' into 'master'
Fix GitAccess specs
Closes #28620
See merge request !9479
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/git_access_spec.rb | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/spec/lib/gitlab/git_access_spec.rb b/spec/lib/gitlab/git_access_spec.rb index a12b4d393d7..d37890de9ae 100644 --- a/spec/lib/gitlab/git_access_spec.rb +++ b/spec/lib/gitlab/git_access_spec.rb @@ -199,7 +199,9 @@ describe Gitlab::GitAccess, lib: true do def stub_git_hooks # Running the `pre-receive` hook is expensive, and not necessary for this test. - allow_any_instance_of(GitHooksService).to receive(:execute).and_yield + allow_any_instance_of(GitHooksService).to receive(:execute) do |service, &block| + block.call(service) + end end def merge_into_protected_branch @@ -232,11 +234,18 @@ describe Gitlab::GitAccess, lib: true do else project.team << [user, role] end + end + + permissions_matrix[role].each do |action, allowed| + context action do + subject { access.send(:check_push_access!, changes[action]) } - permissions_matrix[role].each do |action, allowed| - context action do - subject { access.send(:check_push_access!, changes[action]) } - it { expect(subject.allowed?).to allowed ? be_truthy : be_falsey } + it do + if allowed + expect { subject }.not_to raise_error + else + expect { subject }.to raise_error(Gitlab::GitAccess::UnauthorizedError) + end end end end |