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
path: root/spec
diff options
context:
space:
mode:
authorMark Fletcher <mark@gitlab.com>2018-01-04 23:32:52 +0300
committerMark Fletcher <mark@gitlab.com>2018-01-21 20:24:50 +0300
commit580fa6becf28670c77529993a08fcd0f22491153 (patch)
tree007e68df1c7bf8aab2fcdde3747bd31bf313063e /spec
parent062f5b7126978e08522361e879d7c1723b15c9da (diff)
Yield no results for blank searches on User name, username and email
Given no search term, the `search` and `search_with_secondary_emails` methods will yield an empty result set
Diffstat (limited to 'spec')
-rw-r--r--spec/models/user_spec.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 8d0eaf565a7..762cec9b95e 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -966,6 +966,14 @@ describe User do
expect(described_class.search(user3.username.upcase)).to eq([user3])
end
end
+
+ it 'returns no matches for an empty string' do
+ expect(described_class.search('')).to be_empty
+ end
+
+ it 'returns no matches for nil' do
+ expect(described_class.search(nil)).to be_empty
+ end
end
describe '.search_with_secondary_emails' do
@@ -1020,6 +1028,14 @@ describe User do
it 'does not return users with a matching part of secondary email' do
expect(search_with_secondary_emails(email.email[1..4])).not_to include([email.user])
end
+
+ it 'returns no matches for an empty string' do
+ expect(search_with_secondary_emails('')).to be_empty
+ end
+
+ it 'returns no matches for nil' do
+ expect(search_with_secondary_emails(nil)).to be_empty
+ end
end
describe '.find_by_ssh_key_id' do