disallow whitespace in username

This commit is contained in:
Sarah Mei 2010-10-16 23:34:58 -07:00
parent 798d904e7e
commit f688653936
3 changed files with 8 additions and 2 deletions

View file

@ -38,6 +38,7 @@ class User
key :visible_person_ids, Array
validates_presence_of :username
validates_format_of :username, :without => /\s/
one :person, :class_name => 'Person', :foreign_key => :owner_id

View file

@ -12,9 +12,9 @@ en:
user:
attributes:
username:
taken: "is already taken."
taken: "is already taken"
email:
taken: "is already taken."
taken: "is already taken"
hello: "Hello world"
application:
helper:

View file

@ -52,6 +52,11 @@ describe User do
user.should be_valid
user.username.should == "janie"
end
it "fails if there's whitespace in the middle" do
user = Factory.build(:user, :username => "bobby tables")
user.should_not be_valid
end
end
describe "of email" do