diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-09-04 20:25:43 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-09-04 20:25:43 +0000 |
commit | 9514e4e6ad2d52b0a357b4558cddceb110f5e9ab (patch) | |
tree | a4512fc6f93df5ff48ffa104fb2d557ef606125a /actionpack | |
parent | 40762a48732185ce344cde351dfc6f4a67941f09 (diff) | |
download | rails-9514e4e6ad2d52b0a357b4558cddceb110f5e9ab.tar.gz rails-9514e4e6ad2d52b0a357b4558cddceb110f5e9ab.tar.bz2 rails-9514e4e6ad2d52b0a357b4558cddceb110f5e9ab.zip |
Deprecated the auto-appending of .png to AssetTagHelper#image_tag calls that doesn't have an extension [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4999 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/asset_tag_helper.rb | 8 | ||||
-rw-r--r-- | actionpack/test/template/asset_tag_helper_test.rb | 17 |
3 files changed, 20 insertions, 7 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index c4774df274..1f425f914d 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Deprecated the auto-appending of .png to AssetTagHelper#image_tag calls that doesn't have an extension [DHH] + * Added locals hash to partials, which makes for convenient access of some times available/some times not variables #5491 [wbruce@gmail.com]. Example: # two different render calls diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb index 2d9d7556eb..1f48ab224d 100644 --- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb @@ -122,6 +122,14 @@ module ActionView # * file name, like "rss.gif", that gets expanded to "/images/rss.gif" # * file name without extension, like "logo", that gets expanded to "/images/logo.png" def image_path(source) + unless (source.split("/").last || source).include?(".") || source.blank? + ActiveSupport::Deprecation.warn( + "You've called image_path with a source that doesn't include an extension. " + + "In Rails 2.0, that will not result in .png automatically being appended. " + + "So you should call image_path('#{source}.png') instead" + ) + end + compute_public_path(source, 'images', 'png') end diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb index d5a8cef94c..bc386a535d 100644 --- a/actionpack/test/template/asset_tag_helper_test.rb +++ b/actionpack/test/template/asset_tag_helper_test.rb @@ -113,11 +113,15 @@ class AssetTagHelperTest < Test::Unit::TestCase end def test_image_path - ImagePathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } + ImagePathToTag.each do |method, tag| + assert_deprecated(/image_path/) { assert_dom_equal(tag, eval(method)) } + end end def test_image_tag - ImageLinkToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } + ImageLinkToTag.each do |method, tag| + assert_deprecated(/image_path/) { assert_dom_equal(tag, eval(method)) } + end end def test_timebased_asset_id @@ -145,13 +149,11 @@ class AssetTagHelperNonVhostTest < Test::Unit::TestCase def setup @controller = Class.new do - attr_accessor :request def url_for(options, *parameters_for_method_reference) "http://www.example.com/calloboration/hieraki" end - end.new @request = Class.new do @@ -198,7 +200,6 @@ class AssetTagHelperNonVhostTest < Test::Unit::TestCase %(image_tag("xml")) => %(<img alt="Xml" src="/calloboration/hieraki/images/xml.png" />), %(image_tag("rss", :alt => "rss syndication")) => %(<img alt="rss syndication" src="/calloboration/hieraki/images/rss.png" />), %(image_tag("gold", :size => "45x70")) => %(<img alt="Gold" height="70" src="/calloboration/hieraki/images/gold.png" width="45" />), - %(image_tag("http://www.example.com/images/icon.gif")) => %(<img alt="Icon" src="http://www.example.com/images/icon.gif" />), %(image_tag("symbolize", "size" => "45x70")) => %(<img alt="Symbolize" height="70" src="/calloboration/hieraki/images/symbolize.png" width="45" />) } @@ -230,11 +231,13 @@ class AssetTagHelperNonVhostTest < Test::Unit::TestCase end def test_image_path - ImagePathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } + ImagePathToTag.each { |method, tag| assert_deprecated(/image_path/) { assert_dom_equal(tag, eval(method)) } } end def test_image_tag - ImageLinkToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } + ImageLinkToTag.each do |method, tag| + assert_deprecated(/image_path/) { assert_dom_equal(tag, eval(method)) } + end # Assigning a default alt tag should not cause an exception to be raised assert_nothing_raised { image_tag('') } end |