diff --git a/app/models/person.rb b/app/models/person.rb index 8ec8148f7..0898cce6c 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -68,7 +68,7 @@ class Person end def name - @name ||= if profile.first_name.nil? || profile.first_name.empty? + @name ||= if profile.first_name.nil? || profile.first_name.blank? self.diaspora_handle else "#{profile.first_name.to_s} #{profile.last_name.to_s}" diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index e41617191..17fb722b9 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -216,6 +216,28 @@ describe ApplicationHelper do end end + describe '#person_link' do + before do + @person = Factory(:person) + end + it 'includes the name of the person if they have a first name' do + person_link(@person).should include @person.profile.first_name + end + + it 'uses diaspora handle if the person has no first or last name' do + @person.profile.first_name = nil + @person.profile.last_name = nil + + person_link(@person).should include @person.diaspora_handle + end + + it 'uses diaspora handle if first name and first name are rails#blank?' do + @person.profile.first_name = " " + @person.profile.last_name = " " + + person_link(@person).should include @person.diaspora_handle + end + end context 'performance' do before do @message = "HHello,Hello_, I _am a strong robot.*Hello, I am *a strong robot.Hello, I am a strong robot.Hello, I am a strong robot.Hello, I am a strong robot.Hello, I am a **strong robot.Hello, I am _a _strong *robot**.Hello*, I am a strong "