Commit bf6363a6e942af8f67a3f0d99845f703587ac901

Authored by Daniela Feitosa
Committed by Antonio Terceiro
1 parent 628002e3

Displaying title on article block

(ActionItem1492)
app/models/article_block.rb
... ... @@ -9,7 +9,8 @@ class ArticleBlock < Block
9 9 end
10 10  
11 11 def content
12   - article ? article.to_html : _('Article not selected yet.')
  12 + block_title(title) +
  13 + (article ? article.to_html : _('Article not selected yet.'))
13 14 end
14 15  
15 16 def article_id
... ...
public/stylesheets/application.css
... ... @@ -1403,6 +1403,10 @@ input.disabled {
1403 1403 border: none;
1404 1404 }
1405 1405  
  1406 +.block-title.empty {
  1407 + display: none;
  1408 +}
  1409 +
1406 1410 .invisible-block {
1407 1411 background: url(/images/hachure.png);
1408 1412 opacity: 0.25;
... ...
test/unit/article_block_test.rb
... ... @@ -8,12 +8,11 @@ class ArticleBlockTest < Test::Unit::TestCase
8 8  
9 9 should "take article's content" do
10 10 block = ArticleBlock.new
11   - html = mock
12 11 article = mock
13   - article.expects(:to_html).returns(html)
  12 + article.expects(:to_html).returns("Article content")
14 13 block.stubs(:article).returns(article)
15 14  
16   - assert_same html, block.content
  15 + assert_match(/Article content/, block.content)
17 16 end
18 17  
19 18 should 'refer to an article' do
... ... @@ -52,4 +51,24 @@ class ArticleBlockTest < Test::Unit::TestCase
52 51 assert_nil block.article_id
53 52 end
54 53  
  54 + should "display empty title if title is blank" do
  55 + block = ArticleBlock.new
  56 + article = mock
  57 + article.expects(:to_html).returns("Article content")
  58 + block.expects(:title).returns('')
  59 + block.stubs(:article).returns(article)
  60 +
  61 + assert_equal "<h3 class=\"block-title empty\"></h3>Article content", block.content
  62 + end
  63 +
  64 + should "display title if defined" do
  65 + block = ArticleBlock.new
  66 + article = mock
  67 + article.expects(:to_html).returns("Article content")
  68 + block.expects(:title).returns('Article title')
  69 + block.stubs(:article).returns(article)
  70 +
  71 + assert_equal "<h3 class=\"block-title\">Article title</h3>Article content", block.content
  72 + end
  73 +
55 74 end
... ...