Fixed image_tag so an exception is not thrown just because the image is missing and alt value can't be generated #1395 [Marcel]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1434 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
David Heinemeier Hansson 2005-06-16 06:04:23 +00:00
parent a32303e0fc
commit 89e06ed4c6
3 changed files with 6 additions and 6 deletions

View File

@ -1,5 +1,7 @@
*SVN*
* Fixed image_tag so an exception is not thrown just because the image is missing and alt value can't be generated #1395 [Marcel]
* Added a third parameter to TextHelper#auto_link called href_options for specifying additional tag options on the links generated #1401 [tyler.kovacs@gmail.com]. Example: auto_link(text, :all, { :target => "_blank" }) to have all the generated links open in a new window.
* Fixed TextHelper#highlight to return the text, not nil, if the phrase is blank #1409 [patrick@lenz.sh]

View File

@ -95,7 +95,7 @@ module ActionView
options.symbolize_keys
options[:src] = image_path(source)
options[:alt] ||= source.split("/").last.split(".").first.capitalize
options[:alt] ||= File.basename(options[:src], '.*').split('.').first.capitalize
if options[:size]
options[:width], options[:height] = options[:size].split("x")

View File

@ -166,16 +166,14 @@ class AssetTagHelperNonVhostTest < Test::Unit::TestCase
StyleLinkToTag.each { |method, tag| assert_equal(tag, eval(method)) }
end
def test_image_tag
assert_equal %(<img alt="Gold" height="70" src="/calloboration/hieraki/images/gold.png" width="45" />), image_tag("gold", :size => "45x70")
end
def test_image_path
ImagePathToTag.each { |method, tag| assert_equal(tag, eval(method)) }
end
def test_image_tag
ImageLinkToTag.each { |method, tag| assert_equal(tag, eval(method)) }
# Assigning a default alt tag should not cause an exception to be raised
assert_nothing_raised { image_tag('') }
end
end