From 8dbebef1422ed9fa4e02c2be7f3676a01f044c13 Mon Sep 17 00:00:00 2001 From: vfcosta Date: Tue, 5 Mar 2013 18:09:00 -0300 Subject: [PATCH] Display on forum topics the same information available at blog's post header --- app/helpers/content_viewer_helper.rb | 2 +- app/models/article.rb | 4 ++++ test/unit/content_viewer_helper_test.rb | 9 ++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/helpers/content_viewer_helper.rb b/app/helpers/content_viewer_helper.rb index f6ba368..2696b0a 100644 --- a/app/helpers/content_viewer_helper.rb +++ b/app/helpers/content_viewer_helper.rb @@ -16,7 +16,7 @@ module ContentViewerHelper title = article.display_title if article.kind_of?(UploadedFile) && article.image? title = article.title if title.blank? title = content_tag('h1', h(title), :class => 'title') - if article.belongs_to_blog? + if article.belongs_to_blog? || article.belongs_to_forum? unless args[:no_link] title = content_tag('h1', link_to(article.name, article.url), :class => 'title') end diff --git a/app/models/article.rb b/app/models/article.rb index 57d3781..28392d7 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -291,6 +291,10 @@ class Article < ActiveRecord::Base def belongs_to_blog? self.parent and self.parent.blog? end + + def belongs_to_forum? + self.parent and self.parent.forum? + end def info_from_last_update last_comment = comments.last diff --git a/test/unit/content_viewer_helper_test.rb b/test/unit/content_viewer_helper_test.rb index fd977d5..855e215 100644 --- a/test/unit/content_viewer_helper_test.rb +++ b/test/unit/content_viewer_helper_test.rb @@ -18,8 +18,15 @@ class ContentViewerHelperTest < ActiveSupport::TestCase result = article_title(post) assert_tag_in_string result, :tag => 'span', :content => show_date(post.published_at) end + + should 'display published-at for forum posts' do + forum = fast_create(Forum, :name => 'Forum test', :profile_id => profile.id) + post = TextileArticle.create!(:name => 'post test', :profile => profile, :parent => forum) + result = article_title(post) + assert_tag_in_string result, :tag => 'span', :content => show_date(post.published_at) + end - should 'not display published-at for non-blog posts' do + should 'not display published-at for non-blog and non-forum posts' do article = TextileArticle.create!(:name => 'article for test', :profile => profile) result = article_title(article) assert_no_match /#{show_date(article.published_at)}<\/span>, by .*#{profile.identifier}/, result -- libgit2 0.21.2