diff options
author | Michael Kozono <mkozono@gmail.com> | 2018-05-03 09:10:07 -0700 |
---|---|---|
committer | Michael Kozono <mkozono@gmail.com> | 2018-06-08 09:05:06 -0700 |
commit | c394a7644ed0474dd07d8d588f6abdd6367aaedf (patch) | |
tree | cc0b22e03abab79ec5d3c7ef79b69a7b2e537931 /qa | |
parent | 289a6100ff4f5c9cbcfbb0f1d2719e15b9f49018 (diff) | |
download | gitlab-ce-c394a7644ed0474dd07d8d588f6abdd6367aaedf.tar.gz |
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.
Diffstat (limited to 'qa')
-rw-r--r-- | qa/qa/specs/features/repository/protected_branches_spec.rb | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/qa/qa/specs/features/repository/protected_branches_spec.rb b/qa/qa/specs/features/repository/protected_branches_spec.rb index fcec987ec69..84193359f2f 100644 --- a/qa/qa/specs/features/repository/protected_branches_spec.rb +++ b/qa/qa/specs/features/repository/protected_branches_spec.rb @@ -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 |