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)
|
Person.searchable.where(sql, *tokens)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def name(opts = {})
|
def name(opts = {})
|
||||||
if self.profile.nil?
|
if self.profile.nil?
|
||||||
fix_profile
|
fix_profile
|
||||||
|
|
@ -155,7 +153,8 @@ class Person < ActiveRecord::Base
|
||||||
@first_name ||= if profile.nil? || profile.first_name.nil? || profile.first_name.blank?
|
@first_name ||= if profile.nil? || profile.first_name.nil? || profile.first_name.blank?
|
||||||
self.diaspora_handle.split('@').first
|
self.diaspora_handle.split('@').first
|
||||||
else
|
else
|
||||||
profile.first_name.to_s.split(/\s/).first
|
names = profile.first_name.to_s.split(/\s/)
|
||||||
|
names[0...-1].join(' ')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -277,9 +277,9 @@ describe Person do
|
||||||
alice.person.first_name.should == alice.username
|
alice.person.first_name.should == alice.username
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns first word in first_name if first_name is present' do
|
it 'returns first words in first_name if first_name is present' do
|
||||||
alice.person.profile.update_attributes(:first_name => "Alice Smith")
|
alice.person.profile.update_attributes(:first_name => "First Mid Last")
|
||||||
alice.person.first_name.should == "Alice"
|
alice.person.first_name.should == "First Mid"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue