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 ...@@ -26,38 +26,36 @@ module QA
Capybara.execute_script 'localStorage.clear()' Capybara.execute_script 'localStorage.clear()'
end end
scenario 'user is able to protect a branch' do 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) protected_branch = fabricate_branch(allow_to_push: true)
expect(protected_branch.name).to have_content(branch_name) expect(protected_branch.name).to have_content(branch_name)
expect(protected_branch.push_allowance).to have_content('Developers + Maintainers') 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)
project.visit! project.visit!
Git::Repository.perform do |repository| Git::Repository.perform do |repository|
push_output = push_to_repository(repository) push_output = push_to_repository(repository)
expect(push_output) expect(push_output).to match(/remote: To create a merge request for protected-branch, visit/)
.to match(/remote\: GitLab\: You are not allowed to push code to protected branches on this project/) end
expect(push_output)
.to match(/\[remote rejected\] #{branch_name} -> #{branch_name} \(pre-receive hook declined\)/)
end end
end end
scenario 'authorized users are allowed' do context 'when developers and maintainers are not allowed to push to a protected branch' do
fabricate_branch(allow_to_push: true) scenario 'a push by the owner fails' do
fabricate_branch(allow_to_push: false)
project.visit! project.visit!
Git::Repository.perform do |repository| Git::Repository.perform do |repository|
push_output = push_to_repository(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 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