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

92 lines
2.8 KiB
Ruby
Raw Normal View History

2017-09-10 17:25:29 +05:30
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
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
2016-09-13 17:45:13 +05:30
within(".dropdown.open .dropdown-menu") { click_on access_type_name }
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
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
within(".dropdown.open .dropdown-menu") { click_on access_type_name }
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.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
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