Don't include the parent in search results if it matches

This commit is contained in:
Bob Van Landuyt 2017-09-10 18:55:52 +02:00
parent 79cc3c8e3e
commit 6388b8feec
2 changed files with 7 additions and 1 deletions

View File

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

View File

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