Skip to content
Snippets Groups Projects

fixed last group owner issue and added test

Closed James Lopez requested to merge jameslopez/gitlab-ce:removable-group-owner into master

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

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • James Lopez Added 1 commit:

    Added 1 commit:

    • 1b14bc59 - refactored permissions and added update_project_member ability logic. Also refac…
  • Author Maintainer

    @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.

  • Douwe Maan
    Douwe Maan @DouweM started a thread on the diff
  • 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?
    • I think we need my_members here :)

    • Author Maintainer

      actually, members is another shortcut to project_members - so I have changed my_members and used members instead... Kept the refactoring as that model was very fat already, in my opinion!

  • Douwe Maan
    Douwe Maan @DouweM started a thread on the diff
  • 41 41 include Sortable
    42 42 include AfterCommitQueue
    43 43 include CaseSensitivity
    44 include HasOwners
    • As mentioned, because projects can't have multiple owners like groups can, this doesn't make sense.

  • @james11 Some more comments. We're getting closer but we're not quite there yet—projects, groups, members, abilities are complex stuff.

  • Author Maintainer

    @DouweM thanks for the comments - I will have a look as soon as I have some time.

  • James Lopez Added 1 commit:

    Added 1 commit:

    • c6a0f109 - refactored code as projects only have one owner. Kept some refactoring in place (has_owners concern)
  • James Lopez Added 1 commit:

    Added 1 commit:

  • Author Maintainer

    @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.

  • James Lopez Added 1 commit:

    Added 1 commit:

  • James Lopez Added 1 commit:

    Added 1 commit:

  • James Lopez Added 1 commit:

    Added 1 commit:

    • 56ea71a3 - fixing rubocop - random code not related to the changes
  • Douwe Maan mentioned in merge request !1815 (merged)

    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.

  • Douwe Maan Status changed to closed

    Status changed to closed

  • Robert Speicher mentioned in commit d431f3ec

    mentioned in commit d431f3ec

  • Robert Speicher mentioned in commit 8a1cafeb

    mentioned in commit 8a1cafeb

  • Please register or sign in to reply
    Loading