Commit 3bd3c93b authored by Drew Blessing's avatar Drew Blessing

Test for stale group owner data

parent e41d5ef4
......@@ -104,10 +104,6 @@ class Group < Namespace
end
end
def owners
@owners ||= group_members.owners.includes(:user).map(&:user)
end
def add_users(user_ids, access_level, current_user = nil, skip_notification: false)
user_ids.each do |user_id|
Member.add_user(self.group_members, user_id, access_level, current_user, skip_notification: skip_notification)
......
......@@ -160,18 +160,17 @@ describe Gitlab::LDAP::GroupSync, lib: true do
group_access: Gitlab::Access::DEVELOPER,
provider: 'ldapmain'
)
group1.add_users([user1.id],
group1.add_users([user1.id, user2.id],
Gitlab::Access::OWNER, skip_notification: true)
end
it 'refuses to downgrade the last owner' do
expect { group_sync.sync_groups }
.not_to change {
group1.members.where(
user_id: user1.id,
access_level: Gitlab::Access::OWNER
).any?
}
# Check two users in a loop to uncover any stale group owner data
it 'downgrades one user but not the other' do
group_sync.sync_groups
expect(group1.members.pluck(:access_level).sort)
.to eq([Gitlab::Access::DEVELOPER, Gitlab::Access::OWNER])
end
context 'when user is a member of two groups from different providers' do
......
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