FIX: don't raise an error on integer usernames
This commit is contained in:
parent
2b7e50cab8
commit
81c87df18a
|
@ -39,7 +39,7 @@ module UserNameSuggester
|
|||
end
|
||||
|
||||
def self.sanitize_username(name)
|
||||
name = ActiveSupport::Inflector.transliterate(name)
|
||||
name = ActiveSupport::Inflector.transliterate(name.to_s)
|
||||
# 1. replace characters that aren't allowed with '_'
|
||||
name.gsub!(UsernameValidator::CONFUSING_EXTENSIONS, "_")
|
||||
name.gsub!(/[^\w.-]/, "_")
|
||||
|
|
|
@ -18,6 +18,10 @@ describe UserNameSuggester do
|
|||
expect(UserNameSuggester.suggest(nil)).to eq(nil)
|
||||
end
|
||||
|
||||
it "doesn't raise an error on integer username" do
|
||||
expect(UserNameSuggester.suggest(999)).to eq('999')
|
||||
end
|
||||
|
||||
it 'corrects weird characters' do
|
||||
expect(UserNameSuggester.suggest("Darth%^Vader")).to eq('Darth_Vader')
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue