From 89e06ed4c6191aff7769aeea8842f45df85acf89 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 16 Jun 2005 06:04:23 +0000 Subject: 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 --- actionpack/CHANGELOG | 2 ++ actionpack/lib/action_view/helpers/asset_tag_helper.rb | 2 +- actionpack/test/template/asset_tag_helper_test.rb | 8 +++----- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index e49ae64a99..e733f7b6d6 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -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] diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb index de507c6ceb..32244166d2 100644 --- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb @@ -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") diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb index f558bc1bbc..b1aa2565b7 100644 --- a/actionpack/test/template/asset_tag_helper_test.rb +++ b/actionpack/test/template/asset_tag_helper_test.rb @@ -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 %(Gold), 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 \ No newline at end of file +end -- cgit v1.2.3