mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 07:38:01 +08:00
Fix the build.
This commit is contained in:
parent
1bb485fca5
commit
0916007d01
|
@ -1,4 +1,5 @@
|
|||
module UserNameSuggester
|
||||
GENERIC_NAMES = ['i', 'me', 'info', 'support', 'admin', 'webmaster', 'hello', 'mail', 'office', 'contact', 'team']
|
||||
|
||||
def self.suggest(name, allow_username = nil)
|
||||
return unless name.present?
|
||||
|
@ -11,7 +12,7 @@ module UserNameSuggester
|
|||
# When 'walter@white.com' take 'walter'
|
||||
name = Regexp.last_match[1]
|
||||
# When 'me@eviltrout.com' take 'eviltrout'
|
||||
name = Regexp.last_match[2] if ['i', 'me', 'info', 'support', 'admin', 'webmaster', 'hello', 'mail', 'office', 'contact', 'team'].include?(name)
|
||||
name = Regexp.last_match[2] if GENERIC_NAMES.include?(name)
|
||||
end
|
||||
name
|
||||
end
|
||||
|
|
|
@ -50,11 +50,17 @@ describe UserNameSuggester do
|
|||
end
|
||||
|
||||
it "doesn't suggest reserved usernames" do
|
||||
SiteSetting.reserved_usernames = 'admin|steve|steve1'
|
||||
expect(UserNameSuggester.suggest("admin@hissite.com")).to eq('admin1')
|
||||
SiteSetting.reserved_usernames = 'myadmin|steve|steve1'
|
||||
expect(UserNameSuggester.suggest("myadmin@hissite.com")).to eq('myadmin1')
|
||||
expect(UserNameSuggester.suggest("steve")).to eq('steve2')
|
||||
end
|
||||
|
||||
it "doesn't suggest generic usernames" do
|
||||
UserNameSuggester::GENERIC_NAMES.each do |name|
|
||||
expect(UserNameSuggester.suggest("#{name}@apple.org")).to eq('apple')
|
||||
end
|
||||
end
|
||||
|
||||
it "removes leading character if it is not alphanumeric" do
|
||||
expect(UserNameSuggester.suggest(".myname")).to eq('myname')
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user