Commit 0540de2c963dfc3cf3cfef6e528edc371df21f00

Authored by Daniela Feitosa
Committed by Antonio Terceiro
1 parent ee0f0a5e

ActionItem1276: published_article didn't show first paragraph

app/models/article.rb
@@ -286,7 +286,7 @@ class Article < ActiveRecord::Base @@ -286,7 +286,7 @@ class Article < ActiveRecord::Base
286 end 286 end
287 287
288 def first_paragraph 288 def first_paragraph
289 - body =~ /(.*<\/p>)/ 289 + to_html =~ /(.*<\/p>)/
290 $1 290 $1
291 end 291 end
292 292
test/unit/article_test.rb
@@ -81,6 +81,13 @@ class ArticleTest &lt; Test::Unit::TestCase @@ -81,6 +81,13 @@ class ArticleTest &lt; Test::Unit::TestCase
81 assert_equal 'the body of the article', a.to_html 81 assert_equal 'the body of the article', a.to_html
82 end 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 should 'inform the icon to be used' do 91 should 'inform the icon to be used' do
85 assert_equal 'text-html', Article.new.icon_name 92 assert_equal 'text-html', Article.new.icon_name
86 end 93 end
test/unit/published_article_test.rb
@@ -122,4 +122,13 @@ class PublishedArticleTest &lt; ActiveSupport::TestCase @@ -122,4 +122,13 @@ class PublishedArticleTest &lt; ActiveSupport::TestCase
122 122
123 assert_equal p.parent, new_parent 123 assert_equal p.parent, new_parent
124 end 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 end 134 end