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
public/stylesheets/application.css
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 | ... | ... |