Commit 8dbebef1422ed9fa4e02c2be7f3676a01f044c13
1 parent
3971931c
Exists in
master
and in
28 other branches
Display on forum topics the same information available at blog's post header
Showing
3 changed files
with
13 additions
and
2 deletions
Show diff stats
app/helpers/content_viewer_helper.rb
@@ -16,7 +16,7 @@ module ContentViewerHelper | @@ -16,7 +16,7 @@ module ContentViewerHelper | ||
16 | title = article.display_title if article.kind_of?(UploadedFile) && article.image? | 16 | title = article.display_title if article.kind_of?(UploadedFile) && article.image? |
17 | title = article.title if title.blank? | 17 | title = article.title if title.blank? |
18 | title = content_tag('h1', h(title), :class => 'title') | 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 | unless args[:no_link] | 20 | unless args[:no_link] |
21 | title = content_tag('h1', link_to(article.name, article.url), :class => 'title') | 21 | title = content_tag('h1', link_to(article.name, article.url), :class => 'title') |
22 | end | 22 | end |
app/models/article.rb
@@ -291,6 +291,10 @@ class Article < ActiveRecord::Base | @@ -291,6 +291,10 @@ class Article < ActiveRecord::Base | ||
291 | def belongs_to_blog? | 291 | def belongs_to_blog? |
292 | self.parent and self.parent.blog? | 292 | self.parent and self.parent.blog? |
293 | end | 293 | end |
294 | + | ||
295 | + def belongs_to_forum? | ||
296 | + self.parent and self.parent.forum? | ||
297 | + end | ||
294 | 298 | ||
295 | def info_from_last_update | 299 | def info_from_last_update |
296 | last_comment = comments.last | 300 | 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 |