aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test
diff options
context:
space:
mode:
authorTimm <kaspth@gmail.com>2013-09-14 13:03:51 +0200
committerTimm <kaspth@gmail.com>2014-06-16 21:04:15 +0200
commitb4cfb59f42c8e5b9eeda19ba7565b2e359219a34 (patch)
treed9439ce05349cc6cba17b83e5307d14aba00f59f /actionview/test
parentfacc4f3c0aa4d6affb28797692920a3df64015b8 (diff)
downloadrails-b4cfb59f42c8e5b9eeda19ba7565b2e359219a34.tar.gz
rails-b4cfb59f42c8e5b9eeda19ba7565b2e359219a34.tar.bz2
rails-b4cfb59f42c8e5b9eeda19ba7565b2e359219a34.zip
Moved some tests to scrubbers_test.rb. Added better testing of accessor validation.
Diffstat (limited to 'actionview/test')
-rw-r--r--actionview/test/template/sanitizers_test.rb9
-rw-r--r--actionview/test/template/scrubbers/scrubbers_test.rb18
2 files changed, 21 insertions, 6 deletions
diff --git a/actionview/test/template/sanitizers_test.rb b/actionview/test/template/sanitizers_test.rb
index 48079bf060..c9e696a972 100644
--- a/actionview/test/template/sanitizers_test.rb
+++ b/actionview/test/template/sanitizers_test.rb
@@ -218,20 +218,17 @@ class SanitizersTest < ActionController::TestCase
def test_should_raise_argument_error_if_tags_is_not_enumerable
sanitizer = ActionView::WhiteListSanitizer.new
- e = assert_raise(ArgumentError) do
+ assert_raise(ArgumentError) do
sanitizer.sanitize('<a>some html</a>', :tags => 'foo')
end
-
- assert_equal "You should pass :tags as an Enumerable", e.message
end
def test_should_raise_argument_error_if_attributes_is_not_enumerable
sanitizer = ActionView::WhiteListSanitizer.new
- e = assert_raise(ArgumentError) do
+
+ assert_raise(ArgumentError) do
sanitizer.sanitize('<a>some html</a>', :attributes => 'foo')
end
-
- assert_equal "You should pass :attributes as an Enumerable", e.message
end
def test_should_not_accept_non_loofah_inheriting_scrubber
diff --git a/actionview/test/template/scrubbers/scrubbers_test.rb b/actionview/test/template/scrubbers/scrubbers_test.rb
index 15df5b8e22..a4ef36b1fd 100644
--- a/actionview/test/template/scrubbers/scrubbers_test.rb
+++ b/actionview/test/template/scrubbers/scrubbers_test.rb
@@ -67,6 +67,24 @@ class PermitScrubberTest < ActionView::TestCase
assert_node_skipped 'some text'
end
+ def test_tags_accessor_validation
+ e = assert_raise(ArgumentError) do
+ @scrubber.tags = 'tag'
+ end
+
+ assert_equal "You should pass :tags as an Enumerable", e.message
+ assert_nil @scrubber.tags, "Tags should be nil when validation fails"
+ end
+
+ def test_attributes_accessor_validation
+ e = assert_raise(ArgumentError) do
+ @scrubber.attributes = 'cooler'
+ end
+
+ assert_equal "You should pass :attributes as an Enumerable", e.message
+ assert_nil @scrubber.attributes, "Attributes should be nil when validation fails"
+ end
+
protected
def assert_scrubbed(html, expected = html)
output = Loofah.scrub_fragment(html, @scrubber).to_s