Commit 8dbebef1422ed9fa4e02c2be7f3676a01f044c13

Authored by Victor Costa
1 parent 3971931c

Display on forum topics the same information available at blog's post header

app/helpers/content_viewer_helper.rb
... ... @@ -16,7 +16,7 @@ module ContentViewerHelper
16 16 title = article.display_title if article.kind_of?(UploadedFile) && article.image?
17 17 title = article.title if title.blank?
18 18 title = content_tag('h1', h(title), :class => 'title')
19   - if article.belongs_to_blog?
  19 + if article.belongs_to_blog? || article.belongs_to_forum?
20 20 unless args[:no_link]
21 21 title = content_tag('h1', link_to(article.name, article.url), :class => 'title')
22 22 end
... ...
app/models/article.rb
... ... @@ -291,6 +291,10 @@ class Article < ActiveRecord::Base
291 291 def belongs_to_blog?
292 292 self.parent and self.parent.blog?
293 293 end
  294 +
  295 + def belongs_to_forum?
  296 + self.parent and self.parent.forum?
  297 + end
294 298  
295 299 def info_from_last_update
296 300 last_comment = comments.last
... ...
test/unit/content_viewer_helper_test.rb
... ... @@ -18,8 +18,15 @@ class ContentViewerHelperTest < ActiveSupport::TestCase
18 18 result = article_title(post)
19 19 assert_tag_in_string result, :tag => 'span', :content => show_date(post.published_at)
20 20 end
  21 +
  22 + should 'display published-at for forum posts' do
  23 + forum = fast_create(Forum, :name => 'Forum test', :profile_id => profile.id)
  24 + post = TextileArticle.create!(:name => 'post test', :profile => profile, :parent => forum)
  25 + result = article_title(post)
  26 + assert_tag_in_string result, :tag => 'span', :content => show_date(post.published_at)
  27 + end
21 28  
22   - should 'not display published-at for non-blog posts' do
  29 + should 'not display published-at for non-blog and non-forum posts' do
23 30 article = TextileArticle.create!(:name => 'article for test', :profile => profile)
24 31 result = article_title(article)
25 32 assert_no_match /<span class="date">#{show_date(article.published_at)}<\/span><span class="author">, by .*#{profile.identifier}/, result
... ...