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 'spec/finders/groups_finder_spec.rb')
-rw-r--r--spec/finders/groups_finder_spec.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/finders/groups_finder_spec.rb b/spec/finders/groups_finder_spec.rb
index 481e2983dd7..10a08d7326e 100644
--- a/spec/finders/groups_finder_spec.rb
+++ b/spec/finders/groups_finder_spec.rb
@@ -229,5 +229,36 @@ RSpec.describe GroupsFinder do
end
end
end
+
+ context 'with search' do
+ let_it_be(:parent_group) { create(:group, :public, name: 'Parent Group') }
+ let_it_be(:test_group) { create(:group, :public, path: 'test-path') }
+
+ it 'returns all groups with matching title' do
+ expect(described_class.new(user, { search: 'parent' }).execute).to contain_exactly(parent_group)
+ end
+
+ it 'returns all groups with matching path' do
+ expect(described_class.new(user, { search: 'test' }).execute).to contain_exactly(test_group)
+ end
+
+ it 'does not search in full path if parent is set' do
+ matching_subgroup = create(:group, parent: parent_group, path: "#{parent_group.path}-subgroup")
+
+ expect(described_class.new(user, { search: 'parent', parent: parent_group }).execute).to contain_exactly(matching_subgroup)
+ end
+
+ context 'with group descendants' do
+ let_it_be(:sub_group) { create(:group, :public, name: 'Sub Group', parent: parent_group) }
+
+ let(:params) { { search: parent_group.path } }
+
+ it 'searches in full path if descendant groups are not included' do
+ params[:include_parent_descendants] = false
+
+ expect(described_class.new(user, params).execute).to contain_exactly(parent_group, sub_group)
+ end
+ end
+ end
end
end