No semicolons in names
This commit is contained in:
parent
7bfaf462c8
commit
8a2e0eef7c
2 changed files with 15 additions and 0 deletions
|
|
@ -23,6 +23,8 @@ class Profile < ActiveRecord::Base
|
||||||
|
|
||||||
validates_length_of :first_name, :maximum => 32
|
validates_length_of :first_name, :maximum => 32
|
||||||
validates_length_of :last_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,
|
attr_accessible :first_name, :last_name, :image_url, :image_url_medium,
|
||||||
:image_url_small, :birthday, :gender, :bio, :searchable, :date
|
:image_url_small, :birthday, :gender, :bio, :searchable, :date
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,10 @@ describe Profile do
|
||||||
profile = Factory.build(:profile, :first_name => "Hexagooooooooooooooooooooooooooon")
|
profile = Factory.build(:profile, :first_name => "Hexagooooooooooooooooooooooooooon")
|
||||||
profile.should_not be_valid
|
profile.should_not be_valid
|
||||||
end
|
end
|
||||||
|
it 'cannot have ;' do
|
||||||
|
profile = Factory.build(:profile, :first_name => "Hex;agon")
|
||||||
|
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
|
||||||
|
|
@ -39,6 +43,15 @@ describe Profile do
|
||||||
profile = Factory.build(:profile, :last_name => "Hexagooooooooooooooooooooooooooon")
|
profile = Factory.build(:profile, :last_name => "Hexagooooooooooooooooooooooooooon")
|
||||||
profile.should_not be_valid
|
profile.should_not be_valid
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue