mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Username validation in signup and username change forms
This commit is contained in:
@@ -394,6 +394,20 @@ describe User do
|
||||
end
|
||||
end
|
||||
|
||||
context '.username_valid?' do
|
||||
it 'returns true when username is both valid and available' do
|
||||
User.username_valid?('Available').should be_true
|
||||
end
|
||||
|
||||
it 'returns true when the username is valid but not available' do
|
||||
User.username_valid?(Fabricate(:user).username).should be_true
|
||||
end
|
||||
|
||||
it 'returns false when the username is not valid' do
|
||||
User.username_valid?('not valid.name').should be_false
|
||||
end
|
||||
end
|
||||
|
||||
describe '.suggest_username' do
|
||||
it 'corrects weird characters' do
|
||||
User.suggest_username("Darth%^Vadar").should == "Darth_Vadar"
|
||||
|
||||
Reference in New Issue
Block a user