debian-mirror-gitlab/spec/support/shared_examples/features/protected_branches_access_control_ce_shared_examples.rb

130 lines
4 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2020-03-13 15:44:24 +05:30
RSpec.shared_examples "protected branches > access control > CE" do
2018-03-17 18:26:18 +05:30
ProtectedRefAccess::HUMAN_ACCESS_LEVELS.each do |(access_type_id, access_type_name)|
2016-09-13 17:45:13 +05:30
it "allows creating protected branches that #{access_type_name} can push to" do
2017-09-10 17:25:29 +05:30
visit project_protected_branches_path(project)
2017-08-17 22:00:37 +05:30
2016-09-13 17:45:13 +05:30
set_protected_branch_name('master')
2017-08-17 22:00:37 +05:30
2018-11-08 19:23:39 +05:30
find(".js-allowed-to-merge").click
2019-10-12 21:52:04 +05:30
within('.rspec-allowed-to-merge-dropdown') do
2018-11-08 19:23:39 +05:30
expect(first("li")).to have_content("Roles")
find(:link, 'No one').click
end
2017-09-10 17:25:29 +05:30
within('.js-new-protected-branch') do
2016-09-13 17:45:13 +05:30
allowed_to_push_button = find(".js-allowed-to-push")
unless allowed_to_push_button.text == access_type_name
2018-03-17 18:26:18 +05:30
allowed_to_push_button.click
2018-11-08 19:23:39 +05:30
within(".dropdown.show .dropdown-menu") { click_on access_type_name }
2016-09-13 17:45:13 +05:30
end
end
2017-08-17 22:00:37 +05:30
2016-09-13 17:45:13 +05:30
click_on "Protect"
expect(ProtectedBranch.count).to eq(1)
expect(ProtectedBranch.last.push_access_levels.map(&:access_level)).to eq([access_type_id])
end
it "allows updating protected branches so that #{access_type_name} can push to them" do
2017-09-10 17:25:29 +05:30
visit project_protected_branches_path(project)
2017-08-17 22:00:37 +05:30
2016-09-13 17:45:13 +05:30
set_protected_branch_name('master')
2017-08-17 22:00:37 +05:30
2018-11-08 19:23:39 +05:30
find(".js-allowed-to-merge").click
2019-10-12 21:52:04 +05:30
within('.rspec-allowed-to-merge-dropdown') do
2018-11-08 19:23:39 +05:30
expect(first("li")).to have_content("Roles")
find(:link, 'No one').click
end
find(".js-allowed-to-push").click
2019-10-12 21:52:04 +05:30
within('.rspec-allowed-to-push-dropdown') do
2018-11-08 19:23:39 +05:30
expect(first("li")).to have_content("Roles")
find(:link, 'No one').click
end
2016-09-13 17:45:13 +05:30
click_on "Protect"
expect(ProtectedBranch.count).to eq(1)
within(".protected-branches-list") do
find(".js-allowed-to-push").click
2017-09-10 17:25:29 +05:30
2017-08-17 22:00:37 +05:30
within('.js-allowed-to-push-container') do
expect(first("li")).to have_content("Roles")
2018-03-17 18:26:18 +05:30
find(:link, access_type_name).click
2017-08-17 22:00:37 +05:30
end
2016-09-13 17:45:13 +05:30
end
2017-09-10 17:25:29 +05:30
wait_for_requests
2017-08-17 22:00:37 +05:30
2016-09-13 17:45:13 +05:30
expect(ProtectedBranch.last.push_access_levels.map(&:access_level)).to include(access_type_id)
end
end
2018-03-17 18:26:18 +05:30
ProtectedRefAccess::HUMAN_ACCESS_LEVELS.each do |(access_type_id, access_type_name)|
2016-09-13 17:45:13 +05:30
it "allows creating protected branches that #{access_type_name} can merge to" do
2017-09-10 17:25:29 +05:30
visit project_protected_branches_path(project)
2017-08-17 22:00:37 +05:30
2016-09-13 17:45:13 +05:30
set_protected_branch_name('master')
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
within('.js-new-protected-branch') do
2016-09-13 17:45:13 +05:30
allowed_to_merge_button = find(".js-allowed-to-merge")
unless allowed_to_merge_button.text == access_type_name
allowed_to_merge_button.click
2018-11-08 19:23:39 +05:30
within(".dropdown.show .dropdown-menu") { click_on access_type_name }
2016-09-13 17:45:13 +05:30
end
end
2017-08-17 22:00:37 +05:30
2018-11-08 19:23:39 +05:30
find(".js-allowed-to-push").click
2019-10-12 21:52:04 +05:30
within('.rspec-allowed-to-push-dropdown') do
2018-11-08 19:23:39 +05:30
expect(first("li")).to have_content("Roles")
find(:link, 'No one').click
end
2016-09-13 17:45:13 +05:30
click_on "Protect"
expect(ProtectedBranch.count).to eq(1)
expect(ProtectedBranch.last.merge_access_levels.map(&:access_level)).to eq([access_type_id])
end
it "allows updating protected branches so that #{access_type_name} can merge to them" do
2017-09-10 17:25:29 +05:30
visit project_protected_branches_path(project)
2017-08-17 22:00:37 +05:30
2016-09-13 17:45:13 +05:30
set_protected_branch_name('master')
2017-08-17 22:00:37 +05:30
2018-11-08 19:23:39 +05:30
find(".js-allowed-to-merge").click
2019-10-12 21:52:04 +05:30
within('.rspec-allowed-to-merge-dropdown') do
2018-11-08 19:23:39 +05:30
expect(first("li")).to have_content("Roles")
find(:link, 'No one').click
end
find(".js-allowed-to-push").click
2019-10-12 21:52:04 +05:30
within('.rspec-allowed-to-push-dropdown') do
2018-11-08 19:23:39 +05:30
expect(first("li")).to have_content("Roles")
find(:link, 'No one').click
end
2016-09-13 17:45:13 +05:30
click_on "Protect"
expect(ProtectedBranch.count).to eq(1)
within(".protected-branches-list") do
find(".js-allowed-to-merge").click
2017-08-17 22:00:37 +05:30
within('.js-allowed-to-merge-container') do
expect(first("li")).to have_content("Roles")
2018-03-17 18:26:18 +05:30
find(:link, access_type_name).click
2017-08-17 22:00:37 +05:30
end
2016-09-13 17:45:13 +05:30
end
2017-09-10 17:25:29 +05:30
wait_for_requests
2017-08-17 22:00:37 +05:30
2016-09-13 17:45:13 +05:30
expect(ProtectedBranch.last.merge_access_levels.map(&:access_level)).to include(access_type_id)
end
end
end