summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/finders/group_children_finder.rb2
-rw-r--r--spec/finders/group_children_finder_spec.rb6
2 files changed, 7 insertions, 1 deletions
diff --git a/app/finders/group_children_finder.rb b/app/finders/group_children_finder.rb
index 07b97163c62..9760f9ef802 100644
--- a/app/finders/group_children_finder.rb
+++ b/app/finders/group_children_finder.rb
@@ -52,7 +52,7 @@ class GroupChildrenFinder
end
def subgroups_matching_filter
- all_subgroups.search(params[:filter])
+ all_subgroups.where.not(id: parent_group).search(params[:filter])
end
def subgroups
diff --git a/spec/finders/group_children_finder_spec.rb b/spec/finders/group_children_finder_spec.rb
index 8f83f88bb97..3df153abc6a 100644
--- a/spec/finders/group_children_finder_spec.rb
+++ b/spec/finders/group_children_finder_spec.rb
@@ -60,6 +60,12 @@ describe GroupChildrenFinder do
expect(finder.execute).to contain_exactly(matching_project)
end
+
+ it 'does not include the parent itself' do
+ group.update!(name: 'test')
+
+ expect(finder.execute).not_to include(group)
+ end
end
end
end