diff options
Diffstat (limited to 'qa/qa/specs/features/browser_ui/3_create/repository/push_protected_branch_spec.rb')
-rw-r--r-- | qa/qa/specs/features/browser_ui/3_create/repository/push_protected_branch_spec.rb | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/push_protected_branch_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/push_protected_branch_spec.rb index 5d0f4b215f4..dd80905d184 100644 --- a/qa/qa/specs/features/browser_ui/3_create/repository/push_protected_branch_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/repository/push_protected_branch_spec.rb @@ -17,11 +17,16 @@ module QA Page::Main::Login.perform(&:sign_in_using_credentials) end + after do + # We need to clear localStorage because we're using it for the dropdown, + # and capybara doesn't do this for us. + # https://github.com/teamcapybara/capybara/issues/1702 + Capybara.execute_script 'localStorage.clear()' + end + context 'when developers and maintainers are allowed to push to a protected branch' do it 'user with push rights successfully pushes to the protected branch' do - create_protected_branch(allowed_to_push: { - roles: Resource::ProtectedBranch::Roles::DEVS_AND_MAINTAINERS - }) + create_protected_branch(allow_to_push: true) push = push_new_file(branch_name) @@ -31,19 +36,18 @@ module QA context 'when developers and maintainers are not allowed to push to a protected branch' do it 'user without push rights fails to push to the protected branch' do - create_protected_branch(allowed_to_push: { - roles: Resource::ProtectedBranch::Roles::NO_ONE - }) + create_protected_branch(allow_to_push: false) expect { push_new_file(branch_name) }.to raise_error(QA::Git::Repository::RepositoryCommandError, /remote: GitLab: You are not allowed to push code to protected branches on this project\.([\s\S]+)\[remote rejected\] #{branch_name} -> #{branch_name} \(pre-receive hook declined\)/) end end - def create_protected_branch(allowed_to_push:) + def create_protected_branch(allow_to_push:) Resource::ProtectedBranch.fabricate! do |resource| resource.branch_name = branch_name resource.project = project - resource.allowed_to_push = allowed_to_push + resource.allow_to_push = allow_to_push + resource.protected = true end end |