提交 8cbeec77 编写于 作者: M Mike Stone

image_tag raises an error if size is passed with height and/or width

上级 b29d794b
......@@ -207,6 +207,7 @@ def favicon_link_tag(source='favicon.ico', options={})
# # => <img alt="Icon" class="menu_icon" src="/icons/icon.gif" />
def image_tag(source, options={})
options = options.symbolize_keys
check_for_image_tag_errors(options)
src = options[:src] = path_to_image(source)
......@@ -325,6 +326,12 @@ def extract_dimensions(size)
[size, size]
end
end
def check_for_image_tag_errors(options)
if options[:size] && (options[:height] || options[:width])
raise ArgumentError, "Cannot pass a :size option with a :height or :width option"
end
end
end
end
end
......@@ -464,6 +464,14 @@ def test_image_tag_does_not_modify_options
assert_equal({:size => '16x10'}, options)
end
def test_image_tag_raises_an_error_for_competing_size_arguments
exception = assert_raise(ArgumentError) do
image_tag("gold.png", :height => "100", :width => "200", :size => "45x70")
end
assert_equal("Cannot pass a :size option with a :height or :width option", exception.message)
end
def test_favicon_link_tag
FaviconLinkToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册