diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
commit | b76ae638462ab0f673e5915986070518dd3f9ad3 (patch) | |
tree | bdab0533383b52873be0ec0eb4d3c66598ff8b91 /spec/finders/groups_finder_spec.rb | |
parent | 434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff) |
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'spec/finders/groups_finder_spec.rb')
-rw-r--r-- | spec/finders/groups_finder_spec.rb | 31 |
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 |