This commit is contained in:
Bobby Wilson 2012-11-22 13:00:47 -07:00
parent 76bd782962
commit abd4e17daf
3 changed files with 15 additions and 8 deletions

View file

@ -39,8 +39,10 @@ module PeopleHelper
"<a data-hovercard='#{remote_or_hovercard_link}' #{person_href(person)} class='#{opts[:class]}' #{ ("target=" + opts[:target]) if opts[:target]}>#{h(person.name)}</a>".html_safe
end
def last_post_link(person)
link_to(t('people.last_post'), last_post_person_path(person.to_param)) unless person.posts.empty?
def last_visible_post_for(person, current_user=nil)
unless Post.visible_from_author(person, current_user).empty?
link_to(t('people.last_post'), last_post_person_path(person.to_param))
end
end
def person_image_tag(person, size = :thumb_small)

View file

@ -15,7 +15,7 @@
= person.name
%span.diaspora_handle
= person.diaspora_handle
= last_post_link person
= last_visible_post_for person
.description
- if !person.tag_string.blank? && user_signed_in?

View file

@ -60,18 +60,23 @@ describe PeopleHelper do
end
end
describe '#last_post_link' do
describe '#last_visible_post_for' do
before do
@person = FactoryGirl.create(:person)
end
it "doesn't show a link, if the person has no posts" do
last_post_link(@person).should be_blank
it "doesn't show a link, if the person has no visible posts" do
last_visible_post_for(@person).should be_blank
end
it "shows the link, if the person has at leas one post" do
it "doesn't show a link, if the person has posts but none visible" do
post = FactoryGirl.create(:status_message, :author => @person)
last_post_link(@person).should include last_post_person_path(@person.to_param)
last_visible_post_for(@person).should be_blank
end
it "shows the link, if the person has at least one visible post" do
post = FactoryGirl.create(:status_message, :author => @person, :public => true)
last_visible_post_for(@person).should include last_post_person_path(@person.to_param)
end
end