From 2c7abe1b5682d287b19dde5900087908c976109c Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 26 Oct 2008 16:50:18 +0100 Subject: [PATCH] Fixed bug with asset timestamping when using relative_url_root (Joe Goldwasser) [#1265 status:committed] --- actionpack/CHANGELOG | 5 +++++ actionpack/lib/action_view/helpers/asset_tag_helper.rb | 2 +- actionpack/test/template/asset_tag_helper_test.rb | 8 ++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 3c06c87bb2fe9..f6185d866d510 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,3 +1,8 @@ +*2.2.1 [RC2 or 2.2 final]* + +* Fixed bug with asset timestamping when using relative_url_root #1265 [Joe Goldwasser] + + *2.2.0 [RC1] (October 24th, 2008)* * Fix incorrect closing CDATA delimiter and that HTML::Node.parse would blow up on unclosed CDATA sections [packagethief] diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb index 93d38eb9293d0..8bbe74b7ef51a 100644 --- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb @@ -588,8 +588,8 @@ def compute_public_path(source) source += ".#{extension}" if missing_extension?(source) unless source =~ ProtocolRegexp source = "/#{directory}/#{source}" unless source[0] == ?/ - source = prepend_relative_url_root(source) source = rewrite_asset_path(source) + source = prepend_relative_url_root(source) end source = prepend_asset_host(source) source diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb index 6dc122503598d..bade96fe177b2 100644 --- a/actionpack/test/template/asset_tag_helper_test.rb +++ b/actionpack/test/template/asset_tag_helper_test.rb @@ -248,6 +248,14 @@ def test_timebased_asset_id assert_equal %(Rails), image_tag("rails.png") end + def test_timebased_asset_id_with_relative_url_root + ActionController::Base.relative_url_root = "/collaboration/hieraki" + expected_time = File.stat(File.expand_path(File.dirname(__FILE__) + "/../fixtures/public/images/rails.png")).mtime.to_i.to_s + assert_equal %(Rails), image_tag("rails.png") + ensure + ActionController::Base.relative_url_root = "" + end + def test_should_skip_asset_id_on_complete_url assert_equal %(Rails), image_tag("http://www.example.com/rails.png") end