summaryrefslogtreecommitdiff
path: root/qa/qa/resource/protected_branch.rb
diff options
context:
space:
mode:
Diffstat (limited to 'qa/qa/resource/protected_branch.rb')
-rw-r--r--qa/qa/resource/protected_branch.rb33
1 files changed, 23 insertions, 10 deletions
diff --git a/qa/qa/resource/protected_branch.rb b/qa/qa/resource/protected_branch.rb
index 9c65e0e5a31..9b728fc4c24 100644
--- a/qa/qa/resource/protected_branch.rb
+++ b/qa/qa/resource/protected_branch.rb
@@ -5,7 +5,12 @@ require 'securerandom'
module QA
module Resource
class ProtectedBranch < Base
- attr_accessor :branch_name, :allowed_to_push, :allowed_to_merge, :protected
+ attr_accessor :branch_name,
+ :allowed_to_push,
+ :allowed_to_merge,
+ :protected,
+ :new_branch,
+ :require_code_owner_approval
attribute :project do
Project.fabricate_via_api! do |resource|
@@ -21,11 +26,12 @@ module QA
project_push.commit_message = 'Add new file'
project_push.branch_name = branch_name
project_push.new_branch = true
- project_push.remote_branch = @branch_name
+ project_push.remote_branch = branch_name
end
end
def initialize
+ @new_branch = true
@branch_name = 'test/branch'
@allowed_to_push = {
roles: Resource::ProtectedBranch::Roles::DEVS_AND_MAINTAINERS
@@ -34,22 +40,29 @@ module QA
roles: Resource::ProtectedBranch::Roles::DEVS_AND_MAINTAINERS
}
@protected = false
+ @require_code_owner_approval = true
end
def fabricate!
- populate(:branch)
+ if new_branch
+ populate(:branch)
- project.wait_for_push_new_branch @branch_name
+ project.wait_for_push_new_branch branch_name
+ end
project.visit!
Page::Project::Menu.perform(&:go_to_repository_settings)
Page::Project::Settings::Repository.perform do |setting|
setting.expand_protected_branches do |page|
- page.select_branch(branch_name)
- page.select_allowed_to_merge(allowed_to_merge)
- page.select_allowed_to_push(allowed_to_push)
- page.protect_branch
+ if new_branch
+ page.select_branch(branch_name)
+ page.select_allowed_to_merge(allowed_to_merge)
+ page.select_allowed_to_push(allowed_to_push)
+ page.protect_branch
+ else
+ page.require_code_owner_approval(branch_name) if require_code_owner_approval
+ end
end
end
end
@@ -59,11 +72,11 @@ module QA
end
def api_get_path
- "/projects/#{@project.api_resource[:id]}/protected_branches/#{@branch_name}"
+ "/projects/#{project.id}/protected_branches/#{branch_name}"
end
def api_delete_path
- "/projects/#{@project.api_resource[:id]}/protected_branches/#{@branch_name}"
+ "/projects/#{project.id}/protected_branches/#{branch_name}"
end
class Roles