test/scrubbers_test.rb in rails-html-sanitizer-1.4.4 vs test/scrubbers_test.rb in rails-html-sanitizer-1.5.0
- old
+ new
@@ -64,10 +64,17 @@
html = '<tag>leave me <span>now</span></tag>'
@scrubber.tags = %w(tag)
assert_scrubbed html, '<tag>leave me now</tag>'
end
+ def test_prunes_tags
+ @scrubber = Rails::Html::PermitScrubber.new(prune: true)
+ @scrubber.tags = %w(tag)
+ html = '<tag>leave me <span>now</span></tag>'
+ assert_scrubbed html, '<tag>leave me </tag>'
+ end
+
def test_leaves_comments_when_supplied_as_tag
@scrubber.tags = %w(div comment)
assert_scrubbed('<div>one</div><!-- two --><span>three</span>',
'<div>one</div><!-- two -->three')
end
@@ -154,9 +161,16 @@
def test_targeting_tags_and_attributes_removes_only_them
@scrubber.tags = %w(tag)
@scrubber.attributes = %w(remove)
html = '<tag remove="" other=""></tag><a remove="" other=""></a>'
assert_scrubbed html, '<a other=""></a>'
+ end
+
+ def test_prunes_tags
+ @scrubber = Rails::Html::TargetScrubber.new(prune: true)
+ @scrubber.tags = %w(span)
+ html = '<tag>leave me <span>now</span></tag>'
+ assert_scrubbed html, '<tag>leave me </tag>'
end
end
class TextOnlyScrubberTest < ScrubberTest
def setup