Skip to content
Extraits de code Groupes Projets
Valider cdcb693c rédigé par Justin Wienckowski's avatar Justin Wienckowski
Parcourir les fichiers

Issue #446: Adding 32-character length limit to User#username,...

Issue #446: Adding 32-character length limit to User#username, Profile#first_name, Profile#last_name
parent f1ae95fa
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -24,6 +24,8 @@ class Profile ...@@ -24,6 +24,8 @@ class Profile
key :bio, String key :bio, String
after_validation :strip_names after_validation :strip_names
validates_length_of :first_name, :maximum => 32
validates_length_of :last_name, :maximum => 32
before_save :strip_names before_save :strip_names
......
...@@ -45,7 +45,8 @@ class User ...@@ -45,7 +45,8 @@ class User
before_validation :strip_username, :on => :create before_validation :strip_username, :on => :create
validates_presence_of :username validates_presence_of :username
validates_uniqueness_of :username, :case_sensitive => false validates_uniqueness_of :username, :case_sensitive => false
validates_format_of :username, :with => /\A[A-Za-z0-9_.]+\z/ validates_format_of :username, :with => /\A[A-Za-z0-9_.]+\z/
validates_length_of :username, :maximum => 32
validates_with InvitedUserValidator validates_with InvitedUserValidator
one :person, :class_name => 'Person', :foreign_key => :owner_id one :person, :class_name => 'Person', :foreign_key => :owner_id
......
...@@ -12,6 +12,16 @@ describe Profile do ...@@ -12,6 +12,16 @@ describe Profile do
profile.should be_valid profile.should be_valid
profile.first_name.should == "Shelly" profile.first_name.should == "Shelly"
end end
it "can be 32 characters long" do
profile = Factory.build(:profile, :first_name => "Hexagoooooooooooooooooooooooooon")
profile.should be_valid
end
it "cannot be 33 characters" do
profile = Factory.build(:profile, :first_name => "Hexagooooooooooooooooooooooooooon")
profile.should_not be_valid
end
end end
describe "of last_name" do describe "of last_name" do
it "strips leading and trailing whitespace" do it "strips leading and trailing whitespace" do
...@@ -19,6 +29,16 @@ describe Profile do ...@@ -19,6 +29,16 @@ describe Profile do
profile.should be_valid profile.should be_valid
profile.last_name.should == "Ohba" profile.last_name.should == "Ohba"
end end
it "can be 32 characters long" do
profile = Factory.build(:profile, :last_name => "Hexagoooooooooooooooooooooooooon")
profile.should be_valid
end
it "cannot be 33 characters" do
profile = Factory.build(:profile, :last_name => "Hexagooooooooooooooooooooooooooon")
profile.should_not be_valid
end
end end
end end
end end
...@@ -102,6 +102,16 @@ describe User do ...@@ -102,6 +102,16 @@ describe User do
user = Factory.build(:user, :username => "kittens;") user = Factory.build(:user, :username => "kittens;")
user.should_not be_valid user.should_not be_valid
end end
it "can be 32 characters long" do
user = Factory.build(:user, :username => "hexagoooooooooooooooooooooooooon")
user.should be_valid
end
it "cannot be 33 characters" do
user = Factory.build(:user, :username => "hexagooooooooooooooooooooooooooon")
user.should_not be_valid
end
end end
describe "of email" do describe "of email" do
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter