diff options
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/asset_tag_helper.rb | 1 | ||||
-rw-r--r-- | actionpack/test/template/asset_tag_helper_test.rb | 9 |
3 files changed, 12 insertions, 0 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 1f425f914d..5dca460814 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fixed that AssetTagHelper#image_tag and others using compute_public_path should not modify the incoming source argument (closes #5102) [eule@space.ch] + * 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: diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb index 1f48ab224d..d31b42b565 100644 --- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb @@ -158,6 +158,7 @@ module ActionView private def compute_public_path(source, dir, ext) + source = source.dup source = "/#{dir}/#{source}" unless source.first == "/" || source.include?(":") source << ".#{ext}" unless source.split("/").last.include?(".") source << '?' + rails_asset_id(source) if defined?(RAILS_ROOT) && %r{^[-a-z]+://} !~ source diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb index bc386a535d..e8320291fe 100644 --- a/actionpack/test/template/asset_tag_helper_test.rb +++ b/actionpack/test/template/asset_tag_helper_test.rb @@ -140,6 +140,15 @@ class AssetTagHelperTest < Test::Unit::TestCase ENV["RAILS_ASSET_ID"] = "4500" assert_equal %(<img alt="Rails" src="/images/rails.png?4500" />), image_tag("rails.png") end + + def test_url_dup_image_tag + Object.send(:const_set, :RAILS_ROOT, File.dirname(__FILE__) + "/../fixtures/") + img_url = '/images/rails.png' + url_copy = img_url.dup + image_tag(img_url) + + assert_equal url_copy, img_url + end end class AssetTagHelperNonVhostTest < Test::Unit::TestCase |