diff --git a/app/models/article_block.rb b/app/models/article_block.rb index 45ecb3c..9ea3bf1 100644 --- a/app/models/article_block.rb +++ b/app/models/article_block.rb @@ -9,7 +9,8 @@ class ArticleBlock < Block end def content - article ? article.to_html : _('Article not selected yet.') + block_title(title) + + (article ? article.to_html : _('Article not selected yet.')) end def article_id diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 03e15d0..48f71c2 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -1403,6 +1403,10 @@ input.disabled { border: none; } +.block-title.empty { + display: none; +} + .invisible-block { background: url(/images/hachure.png); opacity: 0.25; diff --git a/test/unit/article_block_test.rb b/test/unit/article_block_test.rb index e494b1f..01ca705 100644 --- a/test/unit/article_block_test.rb +++ b/test/unit/article_block_test.rb @@ -8,12 +8,11 @@ class ArticleBlockTest < Test::Unit::TestCase should "take article's content" do block = ArticleBlock.new - html = mock article = mock - article.expects(:to_html).returns(html) + article.expects(:to_html).returns("Article content") block.stubs(:article).returns(article) - assert_same html, block.content + assert_match(/Article content/, block.content) end should 'refer to an article' do @@ -52,4 +51,24 @@ class ArticleBlockTest < Test::Unit::TestCase assert_nil block.article_id end + should "display empty title if title is blank" do + block = ArticleBlock.new + article = mock + article.expects(:to_html).returns("Article content") + block.expects(:title).returns('') + block.stubs(:article).returns(article) + + assert_equal "

Article content", block.content + end + + should "display title if defined" do + block = ArticleBlock.new + article = mock + article.expects(:to_html).returns("Article content") + block.expects(:title).returns('Article title') + block.stubs(:article).returns(article) + + assert_equal "

Article title

Article content", block.content + end + end -- libgit2 0.21.2