presenter now has a title

This commit is contained in:
Maxwell Salzberg 2012-02-27 18:10:00 -08:00
parent 0df179c514
commit 22cda15aa8
3 changed files with 29 additions and 1 deletions

View file

@ -23,7 +23,8 @@ class PostPresenter
:reshares => self.reshares,
:comments => self.comments,
:participations => self.participations,
:templateName => template_name
:templateName => template_name,
:title => title
})
end
@ -75,6 +76,13 @@ class PostPresenter
end
end
def title
if post.text.present?
post.text
else
I18n.translate('posts.presenter.title', :name => post.author.name)
end
end
def template_name
@template_name ||= TemplatePicker.new(post).template_name
@ -107,4 +115,5 @@ class PostPresenter
def user_signed_in?
current_user.present?
end
end

View file

@ -612,6 +612,8 @@ en:
comment_email_subject: "%{name}'s photo"
posts:
presenter:
title: "A post from %{name}"
show:
destroy: "Delete"
permalink: "permalink"

View file

@ -67,4 +67,21 @@ describe PostPresenter do
@presenter.previous_post_path.should == Rails.application.routes.url_helpers.post_path(@sm)
end
end
describe '#title' do
it 'includes the text if it is present' do
@sm = stub(:text => "lalalalalalala", :author => bob.person)
@presenter.post = @sm
@presenter.title.should == @sm.text
end
context 'with posts without text' do
it ' displays a messaage with the post class' do
@sm = stub(:text => "", :author => bob.person)
@presenter.post = @sm
@presenter.title.should == "A post from #{@sm.author.name}"
end
end
end
end