From 0540de2c963dfc3cf3cfef6e528edc371df21f00 Mon Sep 17 00:00:00 2001 From: Daniela Soares Feitosa Date: Wed, 7 Oct 2009 17:39:27 -0300 Subject: [PATCH] ActionItem1276: published_article didn't show first paragraph --- app/models/article.rb | 2 +- test/unit/article_test.rb | 7 +++++++ test/unit/published_article_test.rb | 9 +++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/models/article.rb b/app/models/article.rb index af25c87..9e05f17 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -286,7 +286,7 @@ class Article < ActiveRecord::Base end def first_paragraph - body =~ /(.*<\/p>)/ + to_html =~ /(.*<\/p>)/ $1 end diff --git a/test/unit/article_test.rb b/test/unit/article_test.rb index c35e329..62c325e 100644 --- a/test/unit/article_test.rb +++ b/test/unit/article_test.rb @@ -81,6 +81,13 @@ class ArticleTest < Test::Unit::TestCase assert_equal 'the body of the article', a.to_html end + should 'provide first paragraph of HTML version' do + profile = create_user('testinguser').person + a = Article.create!(:name => 'my article', :profile_id => profile.id) + a.expects(:body).returns('

the first paragraph of the article

The second paragraph') + assert_equal '

the first paragraph of the article

', a.first_paragraph + end + should 'inform the icon to be used' do assert_equal 'text-html', Article.new.icon_name end diff --git a/test/unit/published_article_test.rb b/test/unit/published_article_test.rb index 9c8cf33..16fb527 100644 --- a/test/unit/published_article_test.rb +++ b/test/unit/published_article_test.rb @@ -122,4 +122,13 @@ class PublishedArticleTest < ActiveSupport::TestCase assert_equal p.parent, new_parent end + + should 'provide first paragraph of HTML version' do + prof = Community.create!(:name => 'test_comm', :identifier => 'test_comm') + a = Article.create!(:name => 'my article', :profile_id => prof.id) + a.expects(:body).returns('

the first paragraph of the article

The second paragraph') + p = PublishedArticle.create(:reference_article => a, :profile => prof) + assert_equal '

the first paragraph of the article

', p.first_paragraph + end + end -- libgit2 0.21.2