Prevent occasional matching on random name by specifying one (#14087)

We could mistakenly be picking up matches on user "name" rather than
user username due to faker giving a name like "Gale" or "Haley" or
"Annalee" which match the search term "ale".

Give an explicitly non-matching pattern for the name string to prevent
this.

Sampling from Faker::Name.name and filtering for case insensitive
matching against the search term shows slightly higher than 1% of
results will match this "ale" triple. Low enough to go unnoticed for a
long time.
This commit is contained in:
Daniel Uber 2021-06-28 09:48:27 -05:00 committed by GitHub
parent b9b1becbe3
commit d585ae2bf8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -58,7 +58,7 @@ RSpec.describe Search::Username, type: :service do
it "finds multiple users whose names have common parts", :aggregate_failures do
alex = create(:user, username: "alex")
alexsmith = create(:user, name: "alexsmith")
rhymes = create(:user, username: "rhymes")
rhymes = create(:user, username: "rhymes", name: "Non-matching Name")
result = described_class.search_documents("ale")
usernames = result.pluck(:username)