Commit e1643e6c authored by James Edwards-Jones's avatar James Edwards-Jones

Cleanup protected branch EE specs, removing unnecessary to_sym

parent c86db115
...@@ -12,6 +12,22 @@ shared_examples "protected branches > access control > EE" do ...@@ -12,6 +12,22 @@ shared_examples "protected branches > access control > EE" do
groups.each { |group| project.project_group_links.create(group: group, group_access: Gitlab::Access::DEVELOPER) } groups.each { |group| project.project_group_links.create(group: group, group_access: Gitlab::Access::DEVELOPER) }
end end
def access_type_ids(git_operation)
ProtectedBranch.last.public_send("#{git_operation}_access_levels")
end
def access_levels(git_operation)
access_type_ids(git_operation).map(&:access_level)
end
def user_ids(git_operation)
access_type_ids(git_operation).map(&:user_id)
end
def group_ids(git_operation)
access_type_ids(git_operation).map(&:group_id)
end
it "allows creating protected branches that roles, users, and groups can #{git_operation} to" do it "allows creating protected branches that roles, users, and groups can #{git_operation} to" do
visit namespace_project_protected_branches_path(project.namespace, project) visit namespace_project_protected_branches_path(project.namespace, project)
...@@ -25,9 +41,9 @@ shared_examples "protected branches > access control > EE" do ...@@ -25,9 +41,9 @@ shared_examples "protected branches > access control > EE" do
within(".protected-branches-list") { expect(page).to have_content('master') } within(".protected-branches-list") { expect(page).to have_content('master') }
expect(ProtectedBranch.count).to eq(1) expect(ProtectedBranch.count).to eq(1)
roles.each { |(access_type_id, _)| expect(ProtectedBranch.last.send("#{git_operation}_access_levels".to_sym).map(&:access_level)).to include(access_type_id) } roles.each { |(access_type_id, _)| expect(access_levels(git_operation)).to include(access_type_id) }
users.each { |user| expect(ProtectedBranch.last.send("#{git_operation}_access_levels".to_sym).map(&:user_id)).to include(user.id) } users.each { |user| expect(user_ids(git_operation)).to include(user.id) }
groups.each { |group| expect(ProtectedBranch.last.send("#{git_operation}_access_levels".to_sym).map(&:group_id)).to include(group.id) } groups.each { |group| expect(group_ids(git_operation)).to include(group.id) }
end end
it "allows updating protected branches so that roles and users can #{git_operation} to it" do it "allows updating protected branches so that roles and users can #{git_operation} to it" do
...@@ -45,9 +61,9 @@ shared_examples "protected branches > access control > EE" do ...@@ -45,9 +61,9 @@ shared_examples "protected branches > access control > EE" do
wait_for_requests wait_for_requests
expect(ProtectedBranch.count).to eq(1) expect(ProtectedBranch.count).to eq(1)
roles.each { |(access_type_id, _)| expect(ProtectedBranch.last.send("#{git_operation}_access_levels".to_sym).map(&:access_level)).to include(access_type_id) } roles.each { |(access_type_id, _)| expect(access_levels(git_operation)).to include(access_type_id) }
users.each { |user| expect(ProtectedBranch.last.send("#{git_operation}_access_levels".to_sym).map(&:user_id)).to include(user.id) } users.each { |user| expect(user_ids(git_operation)).to include(user.id) }
groups.each { |group| expect(ProtectedBranch.last.send("#{git_operation}_access_levels".to_sym).map(&:group_id)).to include(group.id) } groups.each { |group| expect(group_ids(git_operation)).to include(group.id) }
end end
it "allows updating protected branches so that roles and users cannot #{git_operation} to it" do it "allows updating protected branches so that roles and users cannot #{git_operation} to it" do
...@@ -68,7 +84,7 @@ shared_examples "protected branches > access control > EE" do ...@@ -68,7 +84,7 @@ shared_examples "protected branches > access control > EE" do
wait_for_requests wait_for_requests
expect(ProtectedBranch.count).to eq(1) expect(ProtectedBranch.count).to eq(1)
expect(ProtectedBranch.last.send("#{git_operation}_access_levels".to_sym)).to be_empty expect(access_type_ids(git_operation)).to be_empty
end end
it "prepends selected users that can #{git_operation} to" do it "prepends selected users that can #{git_operation} to" do
...@@ -106,8 +122,8 @@ shared_examples "protected branches > access control > EE" do ...@@ -106,8 +122,8 @@ shared_examples "protected branches > access control > EE" do
expect(page).to have_selector '.dropdown-content .is-active', text: users.last.name expect(page).to have_selector '.dropdown-content .is-active', text: users.last.name
expect(ProtectedBranch.count).to eq(1) expect(ProtectedBranch.count).to eq(1)
roles.each { |(access_type_id, _)| expect(ProtectedBranch.last.send("#{git_operation}_access_levels".to_sym).map(&:access_level)).to include(access_type_id) } roles.each { |(access_type_id, _)| expect(access_levels(git_operation)).to include(access_type_id) }
expect(ProtectedBranch.last.send("#{git_operation}_access_levels".to_sym).map(&:user_id)).to include(users.last.id) expect(user_ids(git_operation)).to include(users.last.id)
end end
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