Commit 485ac922 authored by Sean McGivern's avatar Sean McGivern

Fix GitAccess specs

These specs never ran due to incorrect indentation: the `context` blocks
were inside the `before`.

Additionally, `GitHooksService` now has to yield itself to callers, and
`GitAccess` never appears to have had an `allowed?` method.
parent a77b40d4
...@@ -199,7 +199,9 @@ describe Gitlab::GitAccess, lib: true do ...@@ -199,7 +199,9 @@ describe Gitlab::GitAccess, lib: true do
def stub_git_hooks def stub_git_hooks
# Running the `pre-receive` hook is expensive, and not necessary for this test. # 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 end
def merge_into_protected_branch def merge_into_protected_branch
...@@ -232,11 +234,18 @@ describe Gitlab::GitAccess, lib: true do ...@@ -232,11 +234,18 @@ describe Gitlab::GitAccess, lib: true do
else else
project.team << [user, role] project.team << [user, role]
end 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| it do
context action do if allowed
subject { access.send(:check_push_access!, changes[action]) } expect { subject }.not_to raise_error
it { expect(subject.allowed?).to allowed ? be_truthy : be_falsey } else
expect { subject }.to raise_error(Gitlab::GitAccess::UnauthorizedError)
end
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment