Commit d5f5fbd0895c67584a9a6610bb8bcce9cc165630

Authored by Leandro Santos
1 parent c70a99e9

replace Hpricot to Nokogiri

plugins/comment_paragraph/lib/ext/article.rb
... ... @@ -21,12 +21,12 @@ class Article
21 21 def comment_paragraph_plugin_parse_html
22 22 comment_paragraph_plugin_set_initial_value unless persisted?
23 23 return unless comment_paragraph_plugin_activated?
24   -
25 24 if body && (body_changed? || setting_changed?(:comment_paragraph_plugin_activate))
26 25 parsed_paragraphs = []
27 26 updated = body_changed? ? body_change[1] : body
28   - doc = Hpricot(updated)
29   - doc.search("/*").each do |paragraph|
  27 + doc = Nokogiri::HTML(updated).css('body')
  28 +
  29 + doc.children.each do |paragraph|
30 30 if paragraph.to_html =~ /^<div(.*)paragraph_comment(.*)$/ || paragraph.to_html =~ /^<p>\W<\/p>$/
31 31 parsed_paragraphs << paragraph.to_html
32 32 else
... ...
plugins/comment_paragraph/test/unit/allow_comment_test.rb
... ... @@ -32,12 +32,14 @@ class AllowCommentTest &lt; ActiveSupport::TestCase
32 32 end
33 33  
34 34 should 'not parse contents outside content viewer controller' do
  35 + article = fast_create(TextArticle, :profile_id => profile.id, :body => 'inner')
35 36 content = macro.parse({:paragraph_uuid => comment.paragraph_uuid}, article.body, article)
36 37 controller.expects(:kind_of?).with(ContentViewerController).returns(false)
37 38 assert_equal 'inner', instance_eval(&content)
38 39 end
39 40  
40 41 should 'not parse contents if comment_paragraph is not activated' do
  42 + article = fast_create(TextArticle, :profile_id => profile.id, :body => 'inner')
41 43 article.expects(:comment_paragraph_plugin_activated?).returns(false)
42 44 content = macro.parse({:paragraph_uuid => comment.paragraph_uuid}, article.body, article)
43 45 controller.expects(:kind_of?).with(ContentViewerController).returns(true)
... ...