first_name now takes everything but the last word in the name field
This commit is contained in:
parent
03d3e885b5
commit
e71fcea762
2 changed files with 5 additions and 6 deletions
|
|
@ -138,8 +138,6 @@ class Person < ActiveRecord::Base
|
|||
Person.searchable.where(sql, *tokens)
|
||||
end
|
||||
|
||||
|
||||
|
||||
def name(opts = {})
|
||||
if self.profile.nil?
|
||||
fix_profile
|
||||
|
|
@ -155,7 +153,8 @@ class Person < ActiveRecord::Base
|
|||
@first_name ||= if profile.nil? || profile.first_name.nil? || profile.first_name.blank?
|
||||
self.diaspora_handle.split('@').first
|
||||
else
|
||||
profile.first_name.to_s.split(/\s/).first
|
||||
names = profile.first_name.to_s.split(/\s/)
|
||||
names[0...-1].join(' ')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -277,9 +277,9 @@ describe Person do
|
|||
alice.person.first_name.should == alice.username
|
||||
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"
|
||||
it 'returns first words in first_name if first_name is present' do
|
||||
alice.person.profile.update_attributes(:first_name => "First Mid Last")
|
||||
alice.person.first_name.should == "First Mid"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue