diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 75fc1f8..c530262 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -936,4 +936,11 @@ module ApplicationHelper content_for(:head) { stylesheet_link_tag(*args) } end + def article_to_html(article) + content = article.to_html(:page => params[:npage]) + return self.instance_eval(&content) if content.kind_of?(Proc) + content + end + + end diff --git a/app/helpers/content_viewer_helper.rb b/app/helpers/content_viewer_helper.rb index 518ee86..90f3fe8 100644 --- a/app/helpers/content_viewer_helper.rb +++ b/app/helpers/content_viewer_helper.rb @@ -24,12 +24,6 @@ module ContentViewerHelper title end - def article_to_html(article) - content = article.to_html(:page => params[:npage]) - return self.instance_eval(&content) if content.kind_of?(Proc) - content - end - def link_to_comments(article) link_to( number_of_comments(article), article.url.merge(:anchor => 'comments_list') ) end diff --git a/app/models/article_block.rb b/app/models/article_block.rb index 9ea3bf1..c1cff7b 100644 --- a/app/models/article_block.rb +++ b/app/models/article_block.rb @@ -9,8 +9,11 @@ class ArticleBlock < Block end def content - block_title(title) + - (article ? article.to_html : _('Article not selected yet.')) + block = self + lambda do + block_title(block.title) + + (block.article ? article_to_html(block.article) : _('Article not selected yet.')) + end end def article_id diff --git a/test/unit/article_block_test.rb b/test/unit/article_block_test.rb index 01ca705..c4a7057 100644 --- a/test/unit/article_block_test.rb +++ b/test/unit/article_block_test.rb @@ -2,6 +2,8 @@ require File.dirname(__FILE__) + '/../test_helper' class ArticleBlockTest < Test::Unit::TestCase + include ApplicationHelper + should 'describe itself' do assert_not_equal Block.description, ArticleBlock.description end @@ -12,7 +14,7 @@ class ArticleBlockTest < Test::Unit::TestCase article.expects(:to_html).returns("Article content") block.stubs(:article).returns(article) - assert_match(/Article content/, block.content) + assert_match(/Article content/, instance_eval(&block.content)) end should 'refer to an article' do @@ -58,7 +60,7 @@ class ArticleBlockTest < Test::Unit::TestCase block.expects(:title).returns('') block.stubs(:article).returns(article) - assert_equal "
Article content", block.content + assert_equal "Article content", instance_eval(&block.content) end should "display title if defined" do @@ -68,7 +70,45 @@ class ArticleBlockTest < Test::Unit::TestCase block.expects(:title).returns('Article title') block.stubs(:article).returns(article) - assert_equal "