diff --git a/app/presenters/post_presenter.rb b/app/presenters/post_presenter.rb index 3d51ed17e4503756c44001a8ef13a63bf24db13f..8d9a63d60ac8f41067e8a2f8d0bf13cb2aa402d3 100644 --- a/app/presenters/post_presenter.rb +++ b/app/presenters/post_presenter.rb @@ -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 diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index d8d385fe51be40d5a5472973e388fc0820a47f2d..5395aff1f4faf36e35900781f3c013821d312ac2 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -612,6 +612,8 @@ en: comment_email_subject: "%{name}'s photo" posts: + presenter: + title: "A post from %{name}" show: destroy: "Delete" permalink: "permalink" diff --git a/spec/presenters/post_presenter_spec.rb b/spec/presenters/post_presenter_spec.rb index ce2fc9d29a2f8b861171c279d1f439ee574e43d8..2635637707e8f9961ff69d6e3b741f297613d170 100644 --- a/spec/presenters/post_presenter_spec.rb +++ b/spec/presenters/post_presenter_spec.rb @@ -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 \ No newline at end of file