Extract EE specific tests for protected branches/tags
We have the spec files containing EE specific code for spec/features/protected_branches_spec.rb and spec/features/protected_tags_spec.rb. This commit deletes / extracts the CE part of it.
This commit is contained in:
parent
c719bc4966
commit
8f59ea33e7
4 changed files with 60 additions and 27 deletions
|
@ -1,6 +1,8 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'Protected Branches', :js do
|
||||
include ProtectedBranchHelpers
|
||||
|
||||
let(:user) { create(:user) }
|
||||
let(:admin) { create(:admin) }
|
||||
let(:project) { create(:project, :repository) }
|
||||
|
@ -150,27 +152,11 @@ describe 'Protected Branches', :js do
|
|||
end
|
||||
|
||||
describe "access control" do
|
||||
before do
|
||||
stub_licensed_features(protected_refs_for_users: false)
|
||||
end
|
||||
|
||||
include_examples "protected branches > access control > CE"
|
||||
end
|
||||
end
|
||||
|
||||
def set_protected_branch_name(branch_name)
|
||||
find(".js-protected-branch-select").click
|
||||
find(".dropdown-input-field").set(branch_name)
|
||||
click_on("Create wildcard #{branch_name}")
|
||||
end
|
||||
|
||||
def set_defaults
|
||||
find(".js-allowed-to-merge").click
|
||||
within('.qa-allowed-to-merge-dropdown') do
|
||||
expect(first("li")).to have_content("Roles")
|
||||
find(:link, 'No one').click
|
||||
end
|
||||
|
||||
find(".js-allowed-to-push").click
|
||||
within('.qa-allowed-to-push-dropdown') do
|
||||
expect(first("li")).to have_content("Roles")
|
||||
find(:link, 'No one').click
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'Protected Tags', :js do
|
||||
include ProtectedTagHelpers
|
||||
|
||||
let(:user) { create(:user, :admin) }
|
||||
let(:project) { create(:project, :repository) }
|
||||
|
||||
|
@ -8,13 +10,6 @@ describe 'Protected Tags', :js do
|
|||
sign_in(user)
|
||||
end
|
||||
|
||||
def set_protected_tag_name(tag_name)
|
||||
find(".js-protected-tag-select").click
|
||||
find(".dropdown-input-field").set(tag_name)
|
||||
click_on("Create wildcard #{tag_name}")
|
||||
find('.protected-tags-dropdown .dropdown-menu', visible: false)
|
||||
end
|
||||
|
||||
describe "explicit protected tags" do
|
||||
it "allows creating explicit protected tags" do
|
||||
visit project_protected_tags_path(project)
|
||||
|
@ -92,6 +87,10 @@ describe 'Protected Tags', :js do
|
|||
end
|
||||
|
||||
describe "access control" do
|
||||
before do
|
||||
stub_licensed_features(protected_refs_for_users: false)
|
||||
end
|
||||
|
||||
include_examples "protected tags > access control > CE"
|
||||
end
|
||||
end
|
||||
|
|
30
spec/support/protected_branch_helpers.rb
Normal file
30
spec/support/protected_branch_helpers.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module ProtectedBranchHelpers
|
||||
def set_allowed_to(operation, option = 'Maintainers', form: '.js-new-protected-branch')
|
||||
within form do
|
||||
select_elem = find(".js-allowed-to-#{operation}")
|
||||
select_elem.click
|
||||
|
||||
wait_for_requests
|
||||
|
||||
within('.dropdown-content') do
|
||||
Array(option).each { |opt| click_on(opt) }
|
||||
end
|
||||
|
||||
# Enhanced select is used in EE, therefore an extra click is needed.
|
||||
select_elem.click if select_elem['aria-expanded'] == 'true'
|
||||
end
|
||||
end
|
||||
|
||||
def set_protected_branch_name(branch_name)
|
||||
find('.js-protected-branch-select').click
|
||||
find('.dropdown-input-field').set(branch_name)
|
||||
click_on("Create wildcard #{branch_name}")
|
||||
end
|
||||
|
||||
def set_defaults
|
||||
set_allowed_to('merge')
|
||||
set_allowed_to('push')
|
||||
end
|
||||
end
|
18
spec/support/protected_tag_helpers.rb
Normal file
18
spec/support/protected_tag_helpers.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require_relative 'protected_branch_helpers'
|
||||
|
||||
module ProtectedTagHelpers
|
||||
include ::ProtectedBranchHelpers
|
||||
|
||||
def set_allowed_to(operation, option = 'Maintainers', form: '.new-protected-tag')
|
||||
super
|
||||
end
|
||||
|
||||
def set_protected_tag_name(tag_name)
|
||||
find('.js-protected-tag-select').click
|
||||
find('.dropdown-input-field').set(tag_name)
|
||||
click_on("Create wildcard #{tag_name}")
|
||||
find('.protected-tags-dropdown .dropdown-menu', visible: false)
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue