Commit 2141bb048d25c73242e2de2478720f122e42add5

Authored by Rodrigo Souto
2 parents 7c606c01 8dbebef1

Merge commit '8dbebef'

app/helpers/content_viewer_helper.rb
@@ -17,7 +17,7 @@ module ContentViewerHelper @@ -17,7 +17,7 @@ module ContentViewerHelper
17 title = article.display_title if article.kind_of?(UploadedFile) && article.image? 17 title = article.display_title if article.kind_of?(UploadedFile) && article.image?
18 title = article.title if title.blank? 18 title = article.title if title.blank?
19 title = content_tag('h1', h(title), :class => 'title') 19 title = content_tag('h1', h(title), :class => 'title')
20 - if article.belongs_to_blog? 20 + if article.belongs_to_blog? || article.belongs_to_forum?
21 unless args[:no_link] 21 unless args[:no_link]
22 title = content_tag('h1', link_to(article.name, article.url), :class => 'title') 22 title = content_tag('h1', link_to(article.name, article.url), :class => 'title')
23 end 23 end
app/models/article.rb
@@ -310,6 +310,10 @@ class Article < ActiveRecord::Base @@ -310,6 +310,10 @@ class Article < ActiveRecord::Base
310 def belongs_to_blog? 310 def belongs_to_blog?
311 self.parent and self.parent.blog? 311 self.parent and self.parent.blog?
312 end 312 end
  313 +
  314 + def belongs_to_forum?
  315 + self.parent and self.parent.forum?
  316 + end
313 317
314 def info_from_last_update 318 def info_from_last_update
315 last_comment = comments.last 319 last_comment = comments.last
test/unit/content_viewer_helper_test.rb
@@ -18,8 +18,15 @@ class ContentViewerHelperTest < ActiveSupport::TestCase @@ -18,8 +18,15 @@ class ContentViewerHelperTest < ActiveSupport::TestCase
18 result = article_title(post) 18 result = article_title(post)
19 assert_tag_in_string result, :tag => 'span', :content => show_date(post.published_at) 19 assert_tag_in_string result, :tag => 'span', :content => show_date(post.published_at)
20 end 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 article = TextileArticle.create!(:name => 'article for test', :profile => profile) 30 article = TextileArticle.create!(:name => 'article for test', :profile => profile)
24 result = article_title(article) 31 result = article_title(article)
25 assert_no_match /<span class="date">#{show_date(article.published_at)}<\/span><span class="author">, by .*#{profile.identifier}/, result 32 assert_no_match /<span class="date">#{show_date(article.published_at)}<\/span><span class="author">, by .*#{profile.identifier}/, result