diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-07 09:08:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-07 09:08:42 +0300 |
commit | 02b949f3b64f88e97abec62c355ca1b1da2bd460 (patch) | |
tree | fffb942e5c6b9f19d3903a709172423595308643 /spec/finders | |
parent | 3e59f1f11a387ab3e0383f7beea8ea599291a293 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/finders')
-rw-r--r-- | spec/finders/users_finder_spec.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/finders/users_finder_spec.rb b/spec/finders/users_finder_spec.rb index 2e94ca5757a..e0a9237a79b 100644 --- a/spec/finders/users_finder_spec.rb +++ b/spec/finders/users_finder_spec.rb @@ -45,6 +45,46 @@ RSpec.describe UsersFinder do expect(users).to be_empty end + describe 'minimum character limit for search' do + it 'passes use_minimum_char_limit from params' do + search_term = normal_user.username[..1] + expect(User).to receive(:search) + .with(search_term, use_minimum_char_limit: false, with_private_emails: anything) + .once.and_call_original + + described_class.new(user, { search: search_term, use_minimum_char_limit: false }).execute + end + + it 'allows searching with 2 characters when use_minimum_char_limit is false' do + users = described_class + .new(user, { search: normal_user.username[..1], use_minimum_char_limit: false }) + .execute + + expect(users).to include(normal_user) + end + + it 'does not allow searching with 2 characters when use_minimum_char_limit is not set' do + users = described_class + .new(user, search: normal_user.username[..1]) + .execute + + expect(users).to be_empty + end + + context 'when autocomplete_users_use_search_service feature flag is disabled' do + before do + stub_feature_flags(autocomplete_users_use_search_service: false) + end + + it 'does not pass use_minimum_char_limit from params' do + search_term = normal_user.username[..1] + expect(User).to receive(:search).with(search_term, with_private_emails: anything).once.and_call_original + + described_class.new(user, { search: search_term, use_minimum_char_limit: false }).execute + end + end + end + it 'filters by external users' do users = described_class.new(user, external: true).execute |