Commit c394a764 authored by Michael Kozono's avatar Michael Kozono

Reduce spec duration

The former “user is able to protect a branch” test no longer has a lot of value after adding the new “authorized users are allowed to push” test, and its setup is redundant, so we may as well save QA spec time by combining them.
parent 289a6100
......@@ -26,38 +26,36 @@ module QA
Capybara.execute_script 'localStorage.clear()'
end
scenario 'user is able to protect a branch' do
protected_branch = fabricate_branch(allow_to_push: true)
context 'when developers and maintainers are allowed to push to a protected branch' do
scenario 'a push by the owner succeeds' do
protected_branch = fabricate_branch(allow_to_push: true)
expect(protected_branch.name).to have_content(branch_name)
expect(protected_branch.push_allowance).to have_content('Developers + Maintainers')
end
context 'push to protected branch' do
scenario 'unauthorized users are blocked' do
fabricate_branch(allow_to_push: false)
expect(protected_branch.name).to have_content(branch_name)
expect(protected_branch.push_allowance).to have_content('Developers + Maintainers')
project.visit!
Git::Repository.perform do |repository|
push_output = push_to_repository(repository)
expect(push_output)
.to match(/remote\: GitLab\: You are not allowed to push code to protected branches on this project/)
expect(push_output)
.to match(/\[remote rejected\] #{branch_name} -> #{branch_name} \(pre-receive hook declined\)/)
expect(push_output).to match(/remote: To create a merge request for protected-branch, visit/)
end
end
end
scenario 'authorized users are allowed' do
fabricate_branch(allow_to_push: true)
context 'when developers and maintainers are not allowed to push to a protected branch' do
scenario 'a push by the owner fails' do
fabricate_branch(allow_to_push: false)
project.visit!
Git::Repository.perform do |repository|
push_output = push_to_repository(repository)
expect(push_output).to match(/remote: To create a merge request for protected-branch, visit/)
expect(push_output)
.to match(/remote\: GitLab\: You are not allowed to push code to protected branches on this project/)
expect(push_output)
.to match(/\[remote rejected\] #{branch_name} -> #{branch_name} \(pre-receive hook declined\)/)
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