diff options
author | Michael Kozono <mkozono@gmail.com> | 2018-05-24 17:04:59 -0700 |
---|---|---|
committer | Michael Kozono <mkozono@gmail.com> | 2018-06-08 09:05:06 -0700 |
commit | 01400a08a08fe68f96da18a377cda8a1e972480e (patch) | |
tree | 693fb9aa1ebb387d9faeb0d3de944a5d53771c6f /qa/qa/specs/features | |
parent | c5bcae5dd657af0f17219dc708ad33f17bcf3bb1 (diff) | |
download | gitlab-ce-01400a08a08fe68f96da18a377cda8a1e972480e.tar.gz |
Reuse Push factory
Diffstat (limited to 'qa/qa/specs/features')
-rw-r--r-- | qa/qa/specs/features/repository/protected_branches_spec.rb | 53 |
1 files changed, 18 insertions, 35 deletions
diff --git a/qa/qa/specs/features/repository/protected_branches_spec.rb b/qa/qa/specs/features/repository/protected_branches_spec.rb index cce9c104432..491675875b9 100644 --- a/qa/qa/specs/features/repository/protected_branches_spec.rb +++ b/qa/qa/specs/features/repository/protected_branches_spec.rb @@ -7,12 +7,6 @@ module QA resource.name = 'protected-branch-project' end end - given(:location) do - Page::Project::Show.act do - choose_repository_clone_http - repository_location - end - end before do Runtime::Browser.visit(:gitlab, Page::Main::Login) @@ -27,40 +21,32 @@ module QA end context 'when developers and maintainers are allowed to push to a protected branch' do - let!(:protected_branch) { fabricate_branch(allow_to_push: true) } + let!(:protected_branch) { create_protected_branch(allow_to_push: true) } scenario 'user with push rights successfully pushes to the protected branch' do expect(protected_branch.name).to have_content(branch_name) expect(protected_branch.push_allowance).to have_content('Developers + Maintainers') - project.visit! + push = push_new_file(branch_name) - 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/) - end + expect(push.output).to match(/remote: To create a merge request for protected-branch, visit/) end end context 'when developers and maintainers are not allowed to push to a protected branch' do scenario 'user without push rights fails to push to the protected branch' do - fabricate_branch(allow_to_push: false) - - project.visit! + create_protected_branch(allow_to_push: false) - Git::Repository.perform do |repository| - push_output = push_to_repository(repository) + push = push_new_file(branch_name) - 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 + 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 - def fabricate_branch(allow_to_push:) + def create_protected_branch(allow_to_push:) Factory::Resource::Branch.fabricate! do |resource| resource.branch_name = branch_name resource.project = project @@ -69,17 +55,14 @@ module QA end end - def push_to_repository(repository) - repository.uri = location.uri - repository.use_default_credentials - - repository.act do - clone - configure_identity('GitLab QA', 'root@gitlab.com') - checkout('protected-branch') - commit_file('README.md', 'readme content', 'Add a readme') - push_changes('protected-branch') - push_output + def push_new_file(branch) + Factory::Repository::Push.fabricate! do |resource| + resource.project = project + resource.file_name = 'new_file.md' + resource.file_content = '# This is a new file' + resource.commit_message = 'Add new_file.md' + resource.branch_name = branch_name + resource.new_branch = false end end end |