debian-mirror-gitlab/spec/features/protected_branches_spec.rb

94 lines
3.2 KiB
Ruby
Raw Normal View History

2016-08-24 12:49:21 +05:30
require 'spec_helper'
2017-09-10 17:25:29 +05:30
feature 'Protected Branches', js: true do
2016-08-24 12:49:21 +05:30
let(:user) { create(:user, :admin) }
2017-08-17 22:00:37 +05:30
let(:project) { create(:project, :repository) }
2016-08-24 12:49:21 +05:30
2017-09-10 17:25:29 +05:30
before do
sign_in(user)
end
2016-08-24 12:49:21 +05:30
def set_protected_branch_name(branch_name)
2017-08-17 22:00:37 +05:30
find(".js-protected-branch-select").trigger('click')
2016-08-24 12:49:21 +05:30
find(".dropdown-input-field").set(branch_name)
2016-09-13 17:45:13 +05:30
click_on("Create wildcard #{branch_name}")
2016-08-24 12:49:21 +05:30
end
describe "explicit protected branches" do
it "allows creating explicit protected branches" do
2017-09-10 17:25:29 +05:30
visit project_protected_branches_path(project)
2016-08-24 12:49:21 +05:30
set_protected_branch_name('some-branch')
click_on "Protect"
within(".protected-branches-list") { expect(page).to have_content('some-branch') }
expect(ProtectedBranch.count).to eq(1)
expect(ProtectedBranch.last.name).to eq('some-branch')
end
it "displays the last commit on the matching branch if it exists" do
commit = create(:commit, project: project)
project.repository.add_branch(user, 'some-branch', commit.id)
2017-09-10 17:25:29 +05:30
visit project_protected_branches_path(project)
2016-08-24 12:49:21 +05:30
set_protected_branch_name('some-branch')
click_on "Protect"
within(".protected-branches-list") { expect(page).to have_content(commit.id[0..7]) }
end
it "displays an error message if the named branch does not exist" do
2017-09-10 17:25:29 +05:30
visit project_protected_branches_path(project)
2016-08-24 12:49:21 +05:30
set_protected_branch_name('some-branch')
click_on "Protect"
within(".protected-branches-list") { expect(page).to have_content('branch was removed') }
end
end
describe "wildcard protected branches" do
it "allows creating protected branches with a wildcard" do
2017-09-10 17:25:29 +05:30
visit project_protected_branches_path(project)
2016-08-24 12:49:21 +05:30
set_protected_branch_name('*-stable')
click_on "Protect"
within(".protected-branches-list") { expect(page).to have_content('*-stable') }
expect(ProtectedBranch.count).to eq(1)
expect(ProtectedBranch.last.name).to eq('*-stable')
end
it "displays the number of matching branches" do
project.repository.add_branch(user, 'production-stable', 'master')
project.repository.add_branch(user, 'staging-stable', 'master')
2017-09-10 17:25:29 +05:30
visit project_protected_branches_path(project)
2016-08-24 12:49:21 +05:30
set_protected_branch_name('*-stable')
click_on "Protect"
within(".protected-branches-list") { expect(page).to have_content("2 matching branches") }
end
it "displays all the branches matching the wildcard" do
project.repository.add_branch(user, 'production-stable', 'master')
project.repository.add_branch(user, 'staging-stable', 'master')
project.repository.add_branch(user, 'development', 'master')
2016-09-13 17:45:13 +05:30
2017-09-10 17:25:29 +05:30
visit project_protected_branches_path(project)
2016-09-13 17:45:13 +05:30
set_protected_branch_name('*-stable')
click_on "Protect"
2016-08-24 12:49:21 +05:30
2017-09-10 17:25:29 +05:30
visit project_protected_branches_path(project)
2016-08-24 12:49:21 +05:30
click_on "2 matching branches"
within(".protected-branches-list") do
expect(page).to have_content("production-stable")
expect(page).to have_content("staging-stable")
expect(page).not_to have_content("development")
end
end
end
2016-09-13 17:45:13 +05:30
describe "access control" do
include_examples "protected branches > access control > CE"
end
2016-08-24 12:49:21 +05:30
end