Turn Group#owners into a has_many association
What does this MR do?
This turns the regular method Group#owners
into a has_many
association.
Are there points in the code the reviewer needs to double check?
As far as I can tell there's no way to do this without using an intermediate association, but perhaps I'm missing something. The reason an intermediate association is needed is because the supplied Proc is applied to the final association (the one returning users), this means that when using a single has_many
you can't filter out any intermediate rows (e.g. group members).
Why was this MR needed?
This code being a regular method would prevent eager loading of the owners of a Group, turning it into a has_many
association resolves this problem. This was discovered in !4410 (merged).
What are the relevant issue numbers?
None.
Does this MR meet the acceptance criteria?
-
CHANGELOG entry added -
Documentation created/updated -
API support added -
Tests -
Added for this feature/bug -
All builds are passing
-
-
Conform by the style guides -
Branch has no merge conflicts with master
(if you do - rebase it please) -
Squashed related commits together
Merge request reports
Activity
mentioned in merge request !4410 (merged)
Reassigned to @rymai
mentioned in issue #18684 (closed)
@dblessing and I actually had a discussion about this in #18616 (closed) yesterday. There is a bug right now where if you add another user as a owner to a project, he/she loses access completely because the Ability class doesn't look for this. You actually can't add another owner in the UI, but you can do this via the API. @dzaporozhets explained the reasoning of having one and only one owner for a project or user namespace in #5980 (closed).
Edited by Stan HuAdded 1 commit:
- 84e2be5a - Turn Group#owners into a has_many association
@rymai I adjusted the specs based on your suggestions.
Enabled an automatic merge when the build for 84e2be5a succeeds
@yorickpeterse Awesome, thank you!
mentioned in commit 5b4e9938
@yorickpeterse It looks like this will also resolve the issue describe at https://gitlab.com/gitlab-org/gitlab-ce/issues/17764 (stale owners). Can you please confirm?
@dblessing Rails caches associations after the first call so I don't think this will make a difference for that particular case.
@yorickpeterse Hmm, that's disappointing but I understand. I suppose we can add a reload in the
has_owner?
method. If you have other ideas, please post in the linked issue.mentioned in commit aafbfb00
mentioned in merge request gitlab-com/www-gitlab-com!2187 (merged)