use blank instead of empty for the person#name helper

This commit is contained in:
maxwell 2010-12-14 11:30:06 -08:00
parent 2bc849fa90
commit 0bd13ec106
2 changed files with 23 additions and 1 deletions

View file

@ -68,7 +68,7 @@ class Person
end end
def name 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 self.diaspora_handle
else else
"#{profile.first_name.to_s} #{profile.last_name.to_s}" "#{profile.first_name.to_s} #{profile.last_name.to_s}"

View file

@ -216,6 +216,28 @@ describe ApplicationHelper do
end end
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 context 'performance' do
before 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 " @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 "