Commit 435a4698 authored by Rémy Coutable's avatar Rémy Coutable

Move shared examples to their correct place and create new helpers

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent f37b0081
require 'spec_helper'
describe 'Branches', feature: true do
include ProtectedBranchHelpers
let(:project) { create(:project, :public) }
let(:repository) { project.repository }
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
context 'logged in as developer' do
before do
login_as :user
......
require 'spec_helper'
Dir["./spec/features/protected_branches/*.rb"].sort.each { |f| require f }
feature 'Projected Branches', feature: true, js: true do
include ProtectedBranchHelpers
let(:user) { create(:user, :admin) }
let(:project) { create(:project, :repository) }
before { login_as(user) }
def set_allowed_to(operation, option = 'Masters', form: '#new_protected_branch')
within form do
find(".js-allowed-to-#{operation}").trigger('click')
wait_for_ajax
Array(option).each { |opt| click_on(opt) }
find(".js-allowed-to-#{operation}").trigger('click') # needed to submit form in some cases
end
end
def set_protected_branch_name(branch_name)
find(".js-protected-branch-select").trigger('click')
find(".dropdown-input-field").set(branch_name)
click_on("Create wildcard #{branch_name}")
end
describe "explicit protected branches" do
it "allows creating explicit protected branches" do
visit namespace_project_protected_branches_path(project.namespace, project)
......
module ProtectedBranchHelpers
def set_allowed_to(operation, option = 'Masters', form: '#new_protected_branch')
within form do
find(".js-allowed-to-#{operation}").trigger('click')
wait_for_ajax
Array(option).each { |opt| click_on(opt) }
find(".js-allowed-to-#{operation}").trigger('click') # needed to submit form in some cases
end
end
def set_protected_branch_name(branch_name)
find(".js-protected-branch-select").trigger('click')
find(".dropdown-input-field").set(branch_name)
click_on("Create wildcard #{branch_name}")
end
end
RSpec.shared_examples "protected branches > access control > CE" do
shared_examples "protected branches > access control > CE" do
ProtectedBranch::PushAccessLevel.human_access_levels.each do |(access_type_id, access_type_name)|
it "allows creating protected branches that #{access_type_name} can push to" do
visit namespace_project_protected_branches_path(project.namespace, project)
......@@ -31,7 +31,7 @@ RSpec.shared_examples "protected branches > access control > CE" do
within(".protected-branches-list") do
find(".js-allowed-to-push").click
within('.js-allowed-to-push-container') do
expect(first("li")).to have_content("Roles")
click_on access_type_name
......
RSpec.shared_examples "protected branches > access control > EE" do
shared_examples "protected branches > access control > EE" do
[['merge', ProtectedBranch::MergeAccessLevel], ['push', ProtectedBranch::PushAccessLevel]].each do |git_operation, access_level_class|
# Need to set a default for the `git_operation` access level that _isn't_ being tested
other_git_operation = git_operation == 'merge' ? 'push' : 'merge'
......
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