Commit 532cf172 authored by Timothy Andrew's avatar Timothy Andrew

Fix protected branch access control spec to not use `sleep`.

- The spec clicks the `Protect` button and immediately asserts on
  data in the database. Since the `Protect` button results in an AJAX
  call, we need to wait for the UI to update before running assertions.

- Also clean up the `access_levels_data` helper method. We don't need to
  use an explicit `levels` array to store changes since we're using
  `map` already.
parent 8693e4a2
......@@ -31,11 +31,9 @@ module BranchesHelper
end
def access_levels_data(access_levels)
levels = []
access_levels.map do |level|
if level.type == :user
levels << {
{
id: level.id,
type: level.type,
user_id: level.user_id,
......@@ -44,10 +42,8 @@ module BranchesHelper
avatar_url: level.user.avatar_url
}
else
levels << { id: level.id, type: level.type, access_level: level.access_level }
{ id: level.id, type: level.type, access_level: level.access_level }
end
end
levels
end
end
......@@ -17,8 +17,7 @@ RSpec.shared_examples "protected branches > access control > EE" do
click_on "Protect"
sleep 1
within(".protected-branches-list") { expect(page).to have_content('master') }
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) }
users.each { |user| expect(ProtectedBranch.last.send("#{git_operation}_access_levels".to_sym).map(&:user_id)).to include(user.id) }
......
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