diff options
author | Timm <kaspth@gmail.com> | 2013-08-17 11:02:09 +0200 |
---|---|---|
committer | Timm <kaspth@gmail.com> | 2014-06-16 21:04:10 +0200 |
commit | 62171784fe374d101aa7cfcb0d1e32c89a3629f8 (patch) | |
tree | daef8553fa9c9bf8f87cfb85453b41d827866c02 /actionview/test/template | |
parent | c1a786493021b184ebd5729eb21979eab1f774e4 (diff) | |
download | rails-62171784fe374d101aa7cfcb0d1e32c89a3629f8.tar.gz rails-62171784fe374d101aa7cfcb0d1e32c89a3629f8.tar.bz2 rails-62171784fe374d101aa7cfcb0d1e32c89a3629f8.zip |
Simplified the removal of xpaths in remove_xpaths. Added more tests for remove_xpaths.
Diffstat (limited to 'actionview/test/template')
-rw-r--r-- | actionview/test/template/sanitizers_test.rb | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/actionview/test/template/sanitizers_test.rb b/actionview/test/template/sanitizers_test.rb index 6769c765fa..bd5b25a305 100644 --- a/actionview/test/template/sanitizers_test.rb +++ b/actionview/test/template/sanitizers_test.rb @@ -23,23 +23,26 @@ class SanitizersTest < ActionController::TestCase assert_equal %(<section><header></header><p>hello </p></section>), sanitizer.remove_xpaths(html, %w(.//script)) end - def test_remove_xpaths_not_enumerable_xpaths_parameter + def test_remove_xpaths_called_with_faulty_xpath sanitizer = ActionView::Sanitizer.new - assert_raises NoMethodError do - sanitizer.remove_xpaths('<h1>hello<h1>', './not_enumerable') + assert_raises Nokogiri::XML::XPath::SyntaxError do + sanitizer.remove_xpaths('<h1>hello<h1>', %w(..faulty_xpath)) end end - def test_remove_xpaths_faulty_xpath + def test_remove_xpaths_called_with_xpath_string sanitizer = ActionView::Sanitizer.new - assert_raises Nokogiri::XML::XPath::SyntaxError do - sanitizer.remove_xpaths('<h1>hello<h1>', %w(..faulty_xpath)) - end + assert_equal '', sanitizer.remove_xpaths('<a></a>', './/a') + end + + def test_remove_xpaths_called_with_enumerable_xpaths + sanitizer = ActionView::Sanitizer.new + assert_equal '', sanitizer.remove_xpaths('<a><span></span></a>', %w(.//a .//span)) end def test_remove_xpaths_called_with_string_returns_string sanitizer = ActionView::Sanitizer.new - assert '<a></a>', sanitizer.remove_xpaths('<a></a>', []) + assert_equal '<a></a>', sanitizer.remove_xpaths('<a></a>', []) end def test_remove_xpaths_called_with_fragment_returns_fragment |