Skip to content
Snippets Groups Projects
Commit 2c66bbbe authored by Raphael's avatar Raphael
Browse files

Strip profile names, resolve 357

parent 962f282c
No related branches found
No related tags found
No related merge requests found
......@@ -19,6 +19,8 @@ class Profile
validates_presence_of :first_name, :last_name
before_save :strip_names
def person_id
self._parent_document.id
end
......@@ -27,4 +29,9 @@ class Profile
self._parent_document
end
private
def strip_names
first_name.strip!
last_name.strip!
end
end
......@@ -9,6 +9,15 @@ describe Profile do
@person = Factory.build(:person)
end
describe 'sanitization' do
it 'strips the names' do
@person.profile = Factory.build(:profile, :first_name => " Bob", :last_name => "Bobson ")
@person.profile.save
@person.profile.first_name.should == "Bob"
@person.profile.last_name.should == "Bobson"
end
end
describe 'requirements' do
it "should include a first name" do
@person.profile = Factory.build(:profile,:first_name => nil)
......@@ -23,7 +32,5 @@ describe Profile do
@person.profile.last_name = "Smith"
@person.profile.valid?.should be true
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment