From c394a7644ed0474dd07d8d588f6abdd6367aaedf Mon Sep 17 00:00:00 2001 From: Michael Kozono Date: Thu, 3 May 2018 09:10:07 -0700 Subject: Reduce spec duration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .../features/repository/protected_branches_spec.rb | 30 ++++++++++------------ 1 file 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 -- cgit v1.2.1