Merge branch 'master' of github.com:diaspora/diaspora
This commit is contained in:
commit
0a4bf225d0
2 changed files with 16 additions and 2 deletions
|
|
@ -19,6 +19,8 @@ class Profile
|
||||||
|
|
||||||
validates_presence_of :first_name, :last_name
|
validates_presence_of :first_name, :last_name
|
||||||
|
|
||||||
|
before_save :strip_names
|
||||||
|
|
||||||
def person_id
|
def person_id
|
||||||
self._parent_document.id
|
self._parent_document.id
|
||||||
end
|
end
|
||||||
|
|
@ -27,4 +29,9 @@ class Profile
|
||||||
self._parent_document
|
self._parent_document
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def strip_names
|
||||||
|
first_name.strip!
|
||||||
|
last_name.strip!
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,15 @@ describe Profile do
|
||||||
@person = Factory.build(:person)
|
@person = Factory.build(:person)
|
||||||
end
|
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
|
describe 'requirements' do
|
||||||
it "should include a first name" do
|
it "should include a first name" do
|
||||||
@person.profile = Factory.build(:profile,:first_name => nil)
|
@person.profile = Factory.build(:profile,:first_name => nil)
|
||||||
|
|
@ -23,7 +32,5 @@ describe Profile do
|
||||||
@person.profile.last_name = "Smith"
|
@person.profile.last_name = "Smith"
|
||||||
@person.profile.valid?.should be true
|
@person.profile.valid?.should be true
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue