Commit 8f59ea33 authored by Oswaldo Ferreira's avatar Oswaldo Ferreira

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.
parent c719bc49
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
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
before do
stub_licensed_features(protected_refs_for_users: false)
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
include_examples "protected branches > access control > CE"
end
end
end
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
# 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