提交 b4cfb59f 编写于 作者: T Timm

Moved some tests to scrubbers_test.rb. Added better testing of accessor validation.

上级 facc4f3c
......@@ -218,20 +218,17 @@ def test_should_allow_custom_tags_with_custom_attributes
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
......
......@@ -67,6 +67,24 @@ def test_skips_text_nodes
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册