From 52d09638dfc07413956846a6319b145511a15757 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Sat, 16 Jun 2012 09:09:38 -0700 Subject: Merge pull request #6752 from steveklabnik/fix_5680 Respect absolute paths in compute_source_path. --- actionpack/lib/action_view/asset_paths.rb | 8 +++++++- actionpack/test/fixtures/public/foo/baz.css | 3 +++ actionpack/test/template/asset_tag_helper_test.rb | 14 +++++++++++--- 3 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 actionpack/test/fixtures/public/foo/baz.css diff --git a/actionpack/lib/action_view/asset_paths.rb b/actionpack/lib/action_view/asset_paths.rb index f6115dbb1b..c192d3704e 100644 --- a/actionpack/lib/action_view/asset_paths.rb +++ b/actionpack/lib/action_view/asset_paths.rb @@ -33,7 +33,13 @@ module ActionView # Return the filesystem path for the source def compute_source_path(source, dir, ext) source = rewrite_extension(source, dir, ext) if ext - File.join(config.assets_dir, dir, source) + + sources = [] + sources << config.assets_dir + sources << dir unless source[0] == ?/ + sources << source + + File.join(sources) end def is_uri?(path) diff --git a/actionpack/test/fixtures/public/foo/baz.css b/actionpack/test/fixtures/public/foo/baz.css new file mode 100644 index 0000000000..b5173fbef2 --- /dev/null +++ b/actionpack/test/fixtures/public/foo/baz.css @@ -0,0 +1,3 @@ +body { +background: #000; +} diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb index e3f56ffea5..f4dedb0c81 100644 --- a/actionpack/test/template/asset_tag_helper_test.rb +++ b/actionpack/test/template/asset_tag_helper_test.rb @@ -1055,9 +1055,6 @@ class AssetTagHelperTest < ActionView::TestCase assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css')) end - - - def test_caching_stylesheet_include_tag_when_caching_off ENV["RAILS_ASSET_ID"] = "" config.perform_caching = false @@ -1086,6 +1083,17 @@ class AssetTagHelperTest < ActionView::TestCase assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css')) end + + def test_caching_stylesheet_include_tag_with_absolute_uri + ENV["RAILS_ASSET_ID"] = "" + + assert_dom_equal( + %(), + stylesheet_link_tag("/foo/baz", :cache => true) + ) + + FileUtils.rm(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css')) + end end class AssetTagHelperNonVhostTest < ActionView::TestCase -- cgit v1.2.3