From 49bc6a249e2a200216f8a96c36093a2c7a471c9b Mon Sep 17 00:00:00 2001 From: Craig R Webster Date: Sun, 21 Mar 2010 19:35:38 +0000 Subject: Allow customisation of asset path generation using a proc. Set config.action_controller.asset_path_template to a proc that takes one argument - the direct, unchanged asset path - and returns a path to that asset using the scheme that your assets require. This is useful if you have a setup which scales by introducing new application servers where the mtime of the asset files may not be the same as those of the asset files on your previous servers, but it does require your web servers to have knowledge of the asset template paths that you rewrite to so it's not suitable for out-of-the-box use. An example of configuring asset path generation and rewriting these paths using Apache is included in actionpack/lib/action_view/helpers/asset_tag_helper.rb. Signed-off-by: wycats --- actionpack/test/template/asset_tag_helper_test.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'actionpack/test') diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb index c471df861d..43d11df8fe 100644 --- a/actionpack/test/template/asset_tag_helper_test.rb +++ b/actionpack/test/template/asset_tag_helper_test.rb @@ -373,6 +373,15 @@ class AssetTagHelperTest < ActionView::TestCase assert_equal %(Rails), image_tag("rails.png") end + def test_proc_asset_id + @controller.config.asset_path_template = Proc.new do |asset_path| + "/assets.v12345#{asset_path}" + end + + expected_path = "/assets.v12345/images/rails.png" + assert_equal %(Rails), image_tag("rails.png") + end + def test_timebased_asset_id_with_relative_url_root @controller.config.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 -- cgit v1.2.3