No semicolons in names

This commit is contained in:
Raphael 2011-02-02 16:36:12 -08:00
parent 7bfaf462c8
commit 8a2e0eef7c
2 changed files with 15 additions and 0 deletions

View file

@ -23,6 +23,8 @@ class Profile < ActiveRecord::Base
validates_length_of :first_name, :maximum => 32
validates_length_of :last_name, :maximum => 32
validates_format_of :first_name, :with => /\A[^;]+\z/
validates_format_of :last_name, :with => /\A[^;]+\z/
attr_accessible :first_name, :last_name, :image_url, :image_url_medium,
:image_url_small, :birthday, :gender, :bio, :searchable, :date

View file

@ -22,6 +22,10 @@ describe Profile do
profile = Factory.build(:profile, :first_name => "Hexagooooooooooooooooooooooooooon")
profile.should_not be_valid
end
it 'cannot have ;' do
profile = Factory.build(:profile, :first_name => "Hex;agon")
profile.should_not be_valid
end
end
describe "of last_name" do
it "strips leading and trailing whitespace" do
@ -39,6 +43,15 @@ describe Profile do
profile = Factory.build(:profile, :last_name => "Hexagooooooooooooooooooooooooooon")
profile.should_not be_valid
end
it 'cannot have ;' do
profile = Factory.build(:profile, :last_name => "Hex;agon")
profile.should_not be_valid
end
it 'disallows ; with a newline in the string' do
profile = Factory.build(:profile, :last_name => "H\nex;agon")
profile.should_not be_valid
end
end
end