diff options
-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 |