mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: allow a huge number of users to share common prefix
Previously username suggester would give up after 100 attempts at getting a username and fallback to random string. This amends the logic so we do all the work of figuring out a good username in SQL and avoids a large amount of queries in cases where a lot of usernames were used up. This corrects an issue on sites with large numbers of anon users
This commit is contained in:
@@ -10,6 +10,15 @@ describe UserNameSuggester do
|
||||
SiteSetting.max_username_length = 15
|
||||
end
|
||||
|
||||
it "keeps adding numbers to the username" do
|
||||
Fabricate(:user, username: 'sam')
|
||||
Fabricate(:user, username: 'sAm1')
|
||||
Fabricate(:user, username: 'sam2')
|
||||
Fabricate(:user, username: 'sam4')
|
||||
|
||||
expect(UserNameSuggester.suggest('saM')).to eq('saM3')
|
||||
end
|
||||
|
||||
it "doesn't raise an error on nil username" do
|
||||
expect(UserNameSuggester.suggest(nil)).to eq(nil)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user