diff --git a/app/views/blocks/article.html.erb b/app/views/blocks/article.html.erb index 78e8524..1e16825 100644 --- a/app/views/blocks/article.html.erb +++ b/app/views/blocks/article.html.erb @@ -1,11 +1,11 @@ <%= block_title(block.title) %> <% if block.article %> - <%=h - article_to_html(FilePresenter.for(block.article), + <%= + h(article_to_html(FilePresenter.for(block.article), :gallery_view => false, :inside_block => block, # For Blogs and folders :format => block.visualization_format # For Articles and contents - ) + )) %> <% else %> <%= _('Article not selected yet.') %> diff --git a/test/unit/article_block_test.rb b/test/unit/article_block_test.rb index d76eeae..aaa9072 100644 --- a/test/unit/article_block_test.rb +++ b/test/unit/article_block_test.rb @@ -7,15 +7,6 @@ class ArticleBlockTest < ActiveSupport::TestCase assert_not_equal Block.description, ArticleBlock.description end - should "take article's content" do - block = ArticleBlock.new - article = mock - article.expects(:to_html).returns("Article content") - block.stubs(:article).returns(article) - - assert_match(/Article content/, instance_eval(&block.content)) - end - should 'refer to an article' do profile = create_user('testuser').person article = profile.articles.build(:name => 'test article') @@ -85,6 +76,30 @@ class ArticleBlockTest < ActiveSupport::TestCase assert_equal [a],block.available_articles end + protected + include NoosferoTestHelper + +end + +require 'boxes_helper' +require 'block_helper' + +class ArticleBlockViewTest < ActionView::TestCase + include BoxesHelper + + ActionView::Base.send :include, ApplicationHelper + ActionView::Base.send :include, BlockHelper + + should "take article's content" do + block = ArticleBlock.new + article = mock + article.expects(:to_html).returns("Article content") + block.stubs(:article).returns(article) + ActionView::Base.any_instance.stubs(:block_title).returns("") + + assert_match(/Article content/, render_block_content(block)) + end + should "display empty title if title is blank" do block = ArticleBlock.new article = mock @@ -92,7 +107,7 @@ class ArticleBlockTest < ActiveSupport::TestCase block.expects(:title).returns('') block.stubs(:article).returns(article) - assert_equal "

Article content", instance_eval(&block.content) + assert_equal "

\n Article content\n", render_block_content(block) end should "display title if defined" do @@ -102,7 +117,7 @@ class ArticleBlockTest < ActiveSupport::TestCase block.expects(:title).returns('Article title') block.stubs(:article).returns(article) - assert_equal "

Article title

Article content", instance_eval(&block.content) + assert_equal "

Article title

\n Article content\n", render_block_content(block) end should 'display image if article is an image' do @@ -113,7 +128,7 @@ class ArticleBlockTest < ActiveSupport::TestCase block.article = image block.save! - assert_tag_in_string instance_eval(&block.content), + assert_tag_in_string render_block_content(block), :tag => 'img', :attributes => { :src => image.public_filename(:display), @@ -129,7 +144,7 @@ class ArticleBlockTest < ActiveSupport::TestCase block.article = image block.save! - assert_no_match(/Previous/, instance_eval(&block.content)) + assert_no_match(/Previous/, render_block_content(block)) end should 'display link to archive if article is an archive' do @@ -141,11 +156,7 @@ class ArticleBlockTest < ActiveSupport::TestCase block.save! UploadedFile.any_instance.stubs(:url).returns('myhost.mydomain/path/to/file') + assert_tag_in_string render_block_content(block), :tag => 'a', :content => _('Download') - assert_tag_in_string instance_eval(&block.content), :tag => 'a', :content => _('Download') end - - protected - include NoosferoTestHelper - end -- libgit2 0.21.2