more first_name fixing

This commit is contained in:
danielgrippi 2011-10-24 21:34:56 -07:00
parent e71fcea762
commit 19897df1ec
2 changed files with 13 additions and 1 deletions

View file

@ -154,7 +154,9 @@ class Person < ActiveRecord::Base
self.diaspora_handle.split('@').first
else
names = profile.first_name.to_s.split(/\s/)
names[0...-1].join(' ')
str = names[0...-1].join(' ')
str = names[0] if str.blank?
str
end
end

View file

@ -281,6 +281,16 @@ describe Person do
alice.person.profile.update_attributes(:first_name => "First Mid Last")
alice.person.first_name.should == "First Mid"
end
it 'returns first word in first_name if first_name is present' do
alice.person.profile.update_attributes(:first_name => "Alice Smith")
alice.person.first_name.should == "Alice"
end
it 'returns first word in first_name if first_name is present' do
alice.person.profile.update_attributes(:first_name => "Alice")
alice.person.first_name.should == "Alice"
end
end
describe '.search' do