aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-06-16 06:04:23 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-06-16 06:04:23 +0000
commit89e06ed4c6191aff7769aeea8842f45df85acf89 (patch)
treee13b82847a3bff17afa1e43a0ce04a7c0d1e7353
parenta32303e0fcc1dd43de1d1e51442b542deaca8bf5 (diff)
downloadrails-89e06ed4c6191aff7769aeea8842f45df85acf89.tar.gz
rails-89e06ed4c6191aff7769aeea8842f45df85acf89.tar.bz2
rails-89e06ed4c6191aff7769aeea8842f45df85acf89.zip
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
-rw-r--r--actionpack/CHANGELOG2
-rw-r--r--actionpack/lib/action_view/helpers/asset_tag_helper.rb2
-rw-r--r--actionpack/test/template/asset_tag_helper_test.rb8
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 %(<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 \ No newline at end of file
+end