From e71fcea7629769b00f456225e100375fc5051f0d Mon Sep 17 00:00:00 2001 From: danielgrippi Date: Mon, 24 Oct 2011 21:27:21 -0700 Subject: [PATCH] first_name now takes everything but the last word in the name field --- app/models/person.rb | 5 ++--- spec/models/person_spec.rb | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/models/person.rb b/app/models/person.rb index 8ef4c7e45..daa07cde5 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -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 diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index 2c59f9690..4d03ee7c7 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -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