Commit 0540de2c963dfc3cf3cfef6e528edc371df21f00
Committed by
Antonio Terceiro
1 parent
ee0f0a5e
Exists in
staging
and in
42 other branches
ActionItem1276: published_article didn't show first paragraph
Showing
3 changed files
with
17 additions
and
1 deletions
Show diff stats
app/models/article.rb
test/unit/article_test.rb
| ... | ... | @@ -81,6 +81,13 @@ class ArticleTest < Test::Unit::TestCase |
| 81 | 81 | assert_equal 'the body of the article', a.to_html |
| 82 | 82 | end |
| 83 | 83 | |
| 84 | + should 'provide first paragraph of HTML version' do | |
| 85 | + profile = create_user('testinguser').person | |
| 86 | + a = Article.create!(:name => 'my article', :profile_id => profile.id) | |
| 87 | + a.expects(:body).returns('<p>the first paragraph of the article</p> The second paragraph') | |
| 88 | + assert_equal '<p>the first paragraph of the article</p>', a.first_paragraph | |
| 89 | + end | |
| 90 | + | |
| 84 | 91 | should 'inform the icon to be used' do |
| 85 | 92 | assert_equal 'text-html', Article.new.icon_name |
| 86 | 93 | end | ... | ... |
test/unit/published_article_test.rb
| ... | ... | @@ -122,4 +122,13 @@ class PublishedArticleTest < ActiveSupport::TestCase |
| 122 | 122 | |
| 123 | 123 | assert_equal p.parent, new_parent |
| 124 | 124 | end |
| 125 | + | |
| 126 | + should 'provide first paragraph of HTML version' do | |
| 127 | + prof = Community.create!(:name => 'test_comm', :identifier => 'test_comm') | |
| 128 | + a = Article.create!(:name => 'my article', :profile_id => prof.id) | |
| 129 | + a.expects(:body).returns('<p>the first paragraph of the article</p> The second paragraph') | |
| 130 | + p = PublishedArticle.create(:reference_article => a, :profile => prof) | |
| 131 | + assert_equal '<p>the first paragraph of the article</p>', p.first_paragraph | |
| 132 | + end | |
| 133 | + | |
| 125 | 134 | end | ... | ... |