Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/finders/group_members_finder.rb')
-rw-r--r--app/finders/group_members_finder.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/app/finders/group_members_finder.rb b/app/finders/group_members_finder.rb
index 982234f7506..75623d33ef5 100644
--- a/app/finders/group_members_finder.rb
+++ b/app/finders/group_members_finder.rb
@@ -3,6 +3,7 @@
class GroupMembersFinder < UnionFinder
RELATIONS = %i(direct inherited descendants).freeze
DEFAULT_RELATIONS = %i(direct inherited).freeze
+ INVALID_RELATION_TYPE_ERROR_MSG = "is not a valid relation type. Valid relation types are #{RELATIONS.join(', ')}."
RELATIONS_DESCRIPTIONS = {
direct: 'Members in the group itself',
@@ -42,6 +43,8 @@ class GroupMembersFinder < UnionFinder
attr_reader :user, :group
def groups_by_relations(include_relations)
+ check_relation_arguments!(include_relations)
+
case include_relations.sort
when [:inherited]
group.ancestors
@@ -86,6 +89,12 @@ class GroupMembersFinder < UnionFinder
def members_of_groups(groups)
GroupMember.non_request.of_groups(groups)
end
+
+ def check_relation_arguments!(include_relations)
+ unless include_relations & RELATIONS == include_relations
+ raise ArgumentError, "#{(include_relations - RELATIONS).first} #{INVALID_RELATION_TYPE_ERROR_MSG}"
+ end
+ end
end
GroupMembersFinder.prepend_mod_with('GroupMembersFinder')