diff --git a/app/models/user.rb b/app/models/user.rb index ab6f68b0a..8bf676384 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index a2c6a657e..10bfa9070 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -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: diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index b239b0f1a..be5986a75 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -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