presenter now has a title
This commit is contained in:
parent
0df179c514
commit
22cda15aa8
3 changed files with 29 additions and 1 deletions
|
|
@ -23,7 +23,8 @@ class PostPresenter
|
||||||
:reshares => self.reshares,
|
:reshares => self.reshares,
|
||||||
:comments => self.comments,
|
:comments => self.comments,
|
||||||
:participations => self.participations,
|
:participations => self.participations,
|
||||||
:templateName => template_name
|
:templateName => template_name,
|
||||||
|
:title => title
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -75,6 +76,13 @@ class PostPresenter
|
||||||
end
|
end
|
||||||
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
|
def template_name
|
||||||
@template_name ||= TemplatePicker.new(post).template_name
|
@template_name ||= TemplatePicker.new(post).template_name
|
||||||
|
|
@ -107,4 +115,5 @@ class PostPresenter
|
||||||
def user_signed_in?
|
def user_signed_in?
|
||||||
current_user.present?
|
current_user.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -612,6 +612,8 @@ en:
|
||||||
comment_email_subject: "%{name}'s photo"
|
comment_email_subject: "%{name}'s photo"
|
||||||
|
|
||||||
posts:
|
posts:
|
||||||
|
presenter:
|
||||||
|
title: "A post from %{name}"
|
||||||
show:
|
show:
|
||||||
destroy: "Delete"
|
destroy: "Delete"
|
||||||
permalink: "permalink"
|
permalink: "permalink"
|
||||||
|
|
|
||||||
|
|
@ -67,4 +67,21 @@ describe PostPresenter do
|
||||||
@presenter.previous_post_path.should == Rails.application.routes.url_helpers.post_path(@sm)
|
@presenter.previous_post_path.should == Rails.application.routes.url_helpers.post_path(@sm)
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
Loading…
Reference in a new issue