fixed last group owner issue and added test
The change prevents a user that is owner of the group to add itself as master - which would imply adding a privilege to delete themselves from the group being the last user on it.
Added a relevant test.
Should fix #1111 (closed)
Merge request reports
Activity
Added 1 commit:
- 6aa9c21a - fix issue with adding members to project (spotted by test)
@DouweM Had to fix an issue to do with the projects as well - as relevant tests were failing. Not sure if the fix makes sense...
Added 1 commit:
- 1b14bc59 - refactored permissions and added update_project_member ability logic. Also refac…
@DouweM I've updated the MR - I had to guess a bit the way your Ability file works and also had to refactor some stuff, so please have a look, as it was a bit more complicated.
I've been trying to get the build to succeed but it's timing out somehow. Tests pass running them locally though.
- app/models/concerns/has_owners.rb 0 → 100644
10 end 11 12 def my_members 13 raise NotImplementedError, "Expected my_members to be defined in #{self.class.name}" 14 end 15 16 def add_owner(user, current_user = nil) 17 add_user(user, Gitlab::Access::OWNER, current_user) 18 end 19 20 def has_owner?(user) 21 owners.include?(user) 22 end 23 24 def has_master?(user) 25 members.masters.where(user_id: user).any? @james11 Some more comments. We're getting closer but we're not quite there yet—projects, groups, members, abilities are complex stuff.
@DouweM thanks for the comments - I will have a look as soon as I have some time.
Added 1 commit:
- c6a0f109 - refactored code as projects only have one owner. Kept some refactoring in place (has_owners concern)
Added 1 commit:
- fd1b5d64 - updated exception
@DouweM I've updated the MR with your comments but kept some of the refactoring. I'm starting to know a bit more about projects, groups, etc... Hopefully nearly there now!
The build is failing at the moment but I believe it was fine locally.
Added 1 commit:
- 77dd5617 - fixing rubocop indents
Added 1 commit:
- e11bfa6b - fixing rubocop indents
Added 1 commit:
- 56ea71a3 - fixing rubocop - random code not related to the changes
mentioned in merge request !1815 (merged)
@james11 Thanks again for your work! I created !1815 (merged) based on this MR with some added refactoring around the way project and group memberships work.
mentioned in commit d431f3ec
mentioned in commit 8a1cafeb
mentioned in issue gitlab-com/support-forum#353 (closed)