From 645fa76b20701ead4a5d132fdc4ab231af8d4cac Mon Sep 17 00:00:00 2001 From: Florian Staudacher Date: Thu, 9 Aug 2012 15:12:22 +0200 Subject: [PATCH] make the "last post" link show ownly if the person has any posts (fixes #3437) --- app/helpers/people_helper.rb | 4 ++++ app/views/people/_sub_header.html.haml | 2 +- spec/helpers/people_helper_spec.rb | 17 ++++++++++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/app/helpers/people_helper.rb b/app/helpers/people_helper.rb index 4d553adb6..6767ee12c 100644 --- a/app/helpers/people_helper.rb +++ b/app/helpers/people_helper.rb @@ -48,6 +48,10 @@ module PeopleHelper " person.name, :class => 'avatar', :title => person.name, 'data-person_id' => person.id) end diff --git a/app/views/people/_sub_header.html.haml b/app/views/people/_sub_header.html.haml index 8aa6900dc..987f198e1 100644 --- a/app/views/people/_sub_header.html.haml +++ b/app/views/people/_sub_header.html.haml @@ -15,7 +15,7 @@ = person.name %span.diaspora_handle = person.diaspora_handle - = link_to t('people.last_post'), last_post_person_path(person.to_param) + = last_post_link person .description - if !person.profile.tag_string.blank? && user_signed_in? diff --git a/spec/helpers/people_helper_spec.rb b/spec/helpers/people_helper_spec.rb index e6dc2838b..7451ad2e9 100644 --- a/spec/helpers/people_helper_spec.rb +++ b/spec/helpers/people_helper_spec.rb @@ -32,7 +32,7 @@ describe PeopleHelper do describe '#person_link' do before do - @person = Factory(:person) + @person = Factory(:person) end it 'includes the name of the person if they have a first name' do @@ -60,6 +60,21 @@ describe PeopleHelper do end end + describe '#last_post_link' do + before do + @person = Factory(:person) + end + + it "doesn't show a link, if the person has no posts" do + last_post_link(@person).should be_blank + end + + it "shows the link, if the person has at leas one post" do + post = Factory(:status_message, :author => @person) + last_post_link(@person).should include last_post_person_path(@person.to_param) + end + end + describe "#person_href" do it "calls local_or_remote_person_path and passes through the options" do opts = {:absolute => true}