diff options
author | Timm <kaspth@gmail.com> | 2013-09-14 14:32:10 +0200 |
---|---|---|
committer | Timm <kaspth@gmail.com> | 2014-06-16 21:04:15 +0200 |
commit | af05b0150599b77a0c148adf2bf5cdf44ec053e1 (patch) | |
tree | acbbeb4d87909926d3eee9304ae008ea372cdf41 /actionview | |
parent | 15382e9793c53c858cc880f4d2b9d3a77059cdfe (diff) | |
download | rails-af05b0150599b77a0c148adf2bf5cdf44ec053e1.tar.gz rails-af05b0150599b77a0c148adf2bf5cdf44ec053e1.tar.bz2 rails-af05b0150599b77a0c148adf2bf5cdf44ec053e1.zip |
Added tests for TargetScrubber.
Diffstat (limited to 'actionview')
-rw-r--r-- | actionview/test/template/scrubbers/scrubbers_test.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/actionview/test/template/scrubbers/scrubbers_test.rb b/actionview/test/template/scrubbers/scrubbers_test.rb index 61d2c48373..9bf62f6ec3 100644 --- a/actionview/test/template/scrubbers/scrubbers_test.rb +++ b/actionview/test/template/scrubbers/scrubbers_test.rb @@ -167,4 +167,35 @@ class PermitScrubberTest < ScrubberTest assert_equal Loofah::Scrubber::STOP, scrubbing end +end + +class TargetScrubberTest < ScrubberTest + def setup + @scrubber = TargetScrubber.new + end + + def test_targeting_tags_removes_only_them + @scrubber.tags = %w(a h1) + html = '<script></script><a></a><h1></h1>' + assert_scrubbed html, '<script></script>' + end + + def test_targeting_tags_removes_only_them_nested + @scrubber.tags = %w(a) + html = '<tag><a><tag><a></a></tag></a></tag>' + assert_scrubbed html, '<tag><tag></tag></tag>' + end + + def test_targeting_attributes_removes_only_them + @scrubber.attributes = %w(class id) + html = '<a class="a" id="b" onclick="c"></a>' + assert_scrubbed html, '<a onclick="c"></a>' + end + + 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 end
\ No newline at end of file |