mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #18783 from mikestone14/actionview-image-tag-override
Actionview image tag size option override
This commit is contained in:
commit
f17792245f
2 changed files with 15 additions and 0 deletions
|
@ -207,6 +207,7 @@ module ActionView
|
|||
# # => <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 @@ module ActionView
|
|||
[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 @@ class AssetTagHelperTest < ActionView::TestCase
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue