Commit 004aff9e authored by Sean McGivern's avatar Sean McGivern

Merge branch 'osw-separate-ee-side-of-protected-branch' into 'master'

[Port] Extract EE specific tests for protected branches/tags

See merge request gitlab-org/gitlab-ce!27640
parents c4340c65 8f59ea33
require 'spec_helper' require 'spec_helper'
describe 'Protected Branches', :js do describe 'Protected Branches', :js do
include ProtectedBranchHelpers
let(:user) { create(:user) } let(:user) { create(:user) }
let(:admin) { create(:admin) } let(:admin) { create(:admin) }
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
...@@ -150,27 +152,11 @@ describe 'Protected Branches', :js do ...@@ -150,27 +152,11 @@ describe 'Protected Branches', :js do
end end
describe "access control" do describe "access control" do
include_examples "protected branches > access control > CE" before do
end stub_licensed_features(protected_refs_for_users: false)
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 include_examples "protected branches > access control > CE"
within('.qa-allowed-to-push-dropdown') do
expect(first("li")).to have_content("Roles")
find(:link, 'No one').click
end end
end end
end end
require 'spec_helper' require 'spec_helper'
describe 'Protected Tags', :js do describe 'Protected Tags', :js do
include ProtectedTagHelpers
let(:user) { create(:user, :admin) } let(:user) { create(:user, :admin) }
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
...@@ -8,13 +10,6 @@ describe 'Protected Tags', :js do ...@@ -8,13 +10,6 @@ describe 'Protected Tags', :js do
sign_in(user) sign_in(user)
end 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 describe "explicit protected tags" do
it "allows creating explicit protected tags" do it "allows creating explicit protected tags" do
visit project_protected_tags_path(project) visit project_protected_tags_path(project)
...@@ -92,6 +87,10 @@ describe 'Protected Tags', :js do ...@@ -92,6 +87,10 @@ describe 'Protected Tags', :js do
end end
describe "access control" do describe "access control" do
before do
stub_licensed_features(protected_refs_for_users: false)
end
include_examples "protected tags > access control > CE" include_examples "protected tags > access control > CE"
end end
end end
# 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
# 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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment