Merge pull request #3490 from Raven24/last-post-link
make the "last post" link show ownly if the person has any posts
This commit is contained in:
commit
9daa620e73
3 changed files with 21 additions and 2 deletions
|
|
@ -48,6 +48,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?
|
||||
end
|
||||
|
||||
def person_image_tag(person, size = :thumb_small)
|
||||
image_tag(person.profile.image_url(size), :alt => person.name, :class => 'avatar', :title => person.name, 'data-person_id' => person.id)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -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?
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
|
|
|
|||
Loading…
Reference in a new issue