Commit bf6363a6e942af8f67a3f0d99845f703587ac901
Committed by
Antonio Terceiro
1 parent
628002e3
Exists in
master
and in
29 other branches
Displaying title on article block
(ActionItem1492)
Showing
3 changed files
with
28 additions
and
4 deletions
Show diff stats
app/models/article_block.rb
@@ -9,7 +9,8 @@ class ArticleBlock < Block | @@ -9,7 +9,8 @@ class ArticleBlock < Block | ||
9 | end | 9 | end |
10 | 10 | ||
11 | def content | 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 | end | 14 | end |
14 | 15 | ||
15 | def article_id | 16 | def article_id |
public/stylesheets/application.css
@@ -1403,6 +1403,10 @@ input.disabled { | @@ -1403,6 +1403,10 @@ input.disabled { | ||
1403 | border: none; | 1403 | border: none; |
1404 | } | 1404 | } |
1405 | 1405 | ||
1406 | +.block-title.empty { | ||
1407 | + display: none; | ||
1408 | +} | ||
1409 | + | ||
1406 | .invisible-block { | 1410 | .invisible-block { |
1407 | background: url(/images/hachure.png); | 1411 | background: url(/images/hachure.png); |
1408 | opacity: 0.25; | 1412 | opacity: 0.25; |
test/unit/article_block_test.rb
@@ -8,12 +8,11 @@ class ArticleBlockTest < Test::Unit::TestCase | @@ -8,12 +8,11 @@ class ArticleBlockTest < Test::Unit::TestCase | ||
8 | 8 | ||
9 | should "take article's content" do | 9 | should "take article's content" do |
10 | block = ArticleBlock.new | 10 | block = ArticleBlock.new |
11 | - html = mock | ||
12 | article = mock | 11 | article = mock |
13 | - article.expects(:to_html).returns(html) | 12 | + article.expects(:to_html).returns("Article content") |
14 | block.stubs(:article).returns(article) | 13 | block.stubs(:article).returns(article) |
15 | 14 | ||
16 | - assert_same html, block.content | 15 | + assert_match(/Article content/, block.content) |
17 | end | 16 | end |
18 | 17 | ||
19 | should 'refer to an article' do | 18 | should 'refer to an article' do |
@@ -52,4 +51,24 @@ class ArticleBlockTest < Test::Unit::TestCase | @@ -52,4 +51,24 @@ class ArticleBlockTest < Test::Unit::TestCase | ||
52 | assert_nil block.article_id | 51 | assert_nil block.article_id |
53 | end | 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 | end | 74 | end |