diff options
author | Joshua Peek <josh@joshpeek.com> | 2011-03-29 21:40:24 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2011-03-29 21:40:24 -0500 |
commit | 77d8f7a4b71d7f52a7ba6f8bc7f7f6f6ac9b81e0 (patch) | |
tree | 0ce1191b113eb2dd83100eb421d28cde4ad278f4 | |
parent | 651d371a247b0c473fb35a62076e480d95d84a35 (diff) | |
download | rails-77d8f7a4b71d7f52a7ba6f8bc7f7f6f6ac9b81e0.tar.gz rails-77d8f7a4b71d7f52a7ba6f8bc7f7f6f6ac9b81e0.tar.bz2 rails-77d8f7a4b71d7f52a7ba6f8bc7f7f6f6ac9b81e0.zip |
Seperate asset directories
-rw-r--r-- | actionpack/lib/action_view/helpers/sprockets_helper.rb | 4 | ||||
-rw-r--r-- | actionpack/test/fixtures/sprockets/app/javascripts/application.js (renamed from actionpack/test/fixtures/sprockets/app/assets/javascripts/application.js) | 0 | ||||
-rw-r--r-- | actionpack/test/fixtures/sprockets/app/javascripts/dir/xmlhr.js (renamed from actionpack/test/fixtures/sprockets/app/assets/javascripts/dir/xmlhr.js) | 0 | ||||
-rw-r--r-- | actionpack/test/fixtures/sprockets/app/javascripts/xmlhr.js (renamed from actionpack/test/fixtures/sprockets/app/assets/javascripts/xmlhr.js) | 0 | ||||
-rw-r--r-- | actionpack/test/fixtures/sprockets/app/stylesheets/application.css (renamed from actionpack/test/fixtures/sprockets/app/assets/stylesheets/application.css) | 0 | ||||
-rw-r--r-- | actionpack/test/fixtures/sprockets/app/stylesheets/dir/style.css (renamed from actionpack/test/fixtures/sprockets/app/assets/stylesheets/dir/style.css) | 0 | ||||
-rw-r--r-- | actionpack/test/fixtures/sprockets/app/stylesheets/style.css (renamed from actionpack/test/fixtures/sprockets/app/assets/stylesheets/style.css) | 0 | ||||
-rw-r--r-- | actionpack/test/template/sprockets_helper_test.rb | 33 |
8 files changed, 21 insertions, 16 deletions
diff --git a/actionpack/lib/action_view/helpers/sprockets_helper.rb b/actionpack/lib/action_view/helpers/sprockets_helper.rb index 4f19f4bb21..408a2030ab 100644 --- a/actionpack/lib/action_view/helpers/sprockets_helper.rb +++ b/actionpack/lib/action_view/helpers/sprockets_helper.rb @@ -48,7 +48,9 @@ module ActionView end # Fingerprint url - source = assets.path(source, config.perform_caching) + if source =~ /^\/#{dir}\/(.+)/ + source = assets.path($1, config.perform_caching, dir) + end host = compute_asset_host(source) diff --git a/actionpack/test/fixtures/sprockets/app/assets/javascripts/application.js b/actionpack/test/fixtures/sprockets/app/javascripts/application.js index e69de29bb2..e69de29bb2 100644 --- a/actionpack/test/fixtures/sprockets/app/assets/javascripts/application.js +++ b/actionpack/test/fixtures/sprockets/app/javascripts/application.js diff --git a/actionpack/test/fixtures/sprockets/app/assets/javascripts/dir/xmlhr.js b/actionpack/test/fixtures/sprockets/app/javascripts/dir/xmlhr.js index e69de29bb2..e69de29bb2 100644 --- a/actionpack/test/fixtures/sprockets/app/assets/javascripts/dir/xmlhr.js +++ b/actionpack/test/fixtures/sprockets/app/javascripts/dir/xmlhr.js diff --git a/actionpack/test/fixtures/sprockets/app/assets/javascripts/xmlhr.js b/actionpack/test/fixtures/sprockets/app/javascripts/xmlhr.js index e69de29bb2..e69de29bb2 100644 --- a/actionpack/test/fixtures/sprockets/app/assets/javascripts/xmlhr.js +++ b/actionpack/test/fixtures/sprockets/app/javascripts/xmlhr.js diff --git a/actionpack/test/fixtures/sprockets/app/assets/stylesheets/application.css b/actionpack/test/fixtures/sprockets/app/stylesheets/application.css index e69de29bb2..e69de29bb2 100644 --- a/actionpack/test/fixtures/sprockets/app/assets/stylesheets/application.css +++ b/actionpack/test/fixtures/sprockets/app/stylesheets/application.css diff --git a/actionpack/test/fixtures/sprockets/app/assets/stylesheets/dir/style.css b/actionpack/test/fixtures/sprockets/app/stylesheets/dir/style.css index e69de29bb2..e69de29bb2 100644 --- a/actionpack/test/fixtures/sprockets/app/assets/stylesheets/dir/style.css +++ b/actionpack/test/fixtures/sprockets/app/stylesheets/dir/style.css diff --git a/actionpack/test/fixtures/sprockets/app/assets/stylesheets/style.css b/actionpack/test/fixtures/sprockets/app/stylesheets/style.css index e69de29bb2..e69de29bb2 100644 --- a/actionpack/test/fixtures/sprockets/app/assets/stylesheets/style.css +++ b/actionpack/test/fixtures/sprockets/app/stylesheets/style.css diff --git a/actionpack/test/template/sprockets_helper_test.rb b/actionpack/test/template/sprockets_helper_test.rb index f6fd4f5bb4..67aee86d02 100644 --- a/actionpack/test/template/sprockets_helper_test.rb +++ b/actionpack/test/template/sprockets_helper_test.rb @@ -20,7 +20,10 @@ class SprocketsHelperTest < ActionView::TestCase @controller.request = @request @assets = Sprockets::Environment.new - @assets.paths << FIXTURES.join("sprockets/app/assets") + @assets.paths << FIXTURES.join("sprockets/app/javascripts") + @assets.paths << FIXTURES.join("sprockets/app/stylesheets") + + config.perform_caching = true end def url_for(*args) @@ -28,12 +31,12 @@ class SprocketsHelperTest < ActionView::TestCase end test "javascript path" do - assert_equal "/javascripts/application-d41d8cd98f00b204e9800998ecf8427e.js", + assert_equal "/assets/application-d41d8cd98f00b204e9800998ecf8427e.js", sprockets_javascript_path(:application) - assert_equal "/javascripts/xmlhr-d41d8cd98f00b204e9800998ecf8427e.js", + assert_equal "/assets/xmlhr-d41d8cd98f00b204e9800998ecf8427e.js", sprockets_javascript_path("xmlhr") - assert_equal "/javascripts/dir/xmlhr-d41d8cd98f00b204e9800998ecf8427e.js", + assert_equal "/assets/dir/xmlhr-d41d8cd98f00b204e9800998ecf8427e.js", sprockets_javascript_path("dir/xmlhr.js") assert_equal "/dir/xmlhr.js", @@ -46,24 +49,24 @@ class SprocketsHelperTest < ActionView::TestCase end test "javascript include tag" do - assert_equal '<script src="/javascripts/application-d41d8cd98f00b204e9800998ecf8427e.js" type="text/javascript"></script>', + assert_equal '<script src="/assets/application-d41d8cd98f00b204e9800998ecf8427e.js" type="text/javascript"></script>', sprockets_javascript_include_tag(:application) - assert_equal '<script src="/javascripts/xmlhr-d41d8cd98f00b204e9800998ecf8427e.js" type="text/javascript"></script>', + assert_equal '<script src="/assets/xmlhr-d41d8cd98f00b204e9800998ecf8427e.js" type="text/javascript"></script>', sprockets_javascript_include_tag("xmlhr") - assert_equal '<script src="/javascripts/xmlhr-d41d8cd98f00b204e9800998ecf8427e.js" type="text/javascript"></script>', + assert_equal '<script src="/assets/xmlhr-d41d8cd98f00b204e9800998ecf8427e.js" type="text/javascript"></script>', sprockets_javascript_include_tag("xmlhr.js") assert_equal '<script src="http://www.railsapplication.com/xmlhr" type="text/javascript"></script>', sprockets_javascript_include_tag("http://www.railsapplication.com/xmlhr") end test "stylesheet path" do - assert_equal "/stylesheets/application-d41d8cd98f00b204e9800998ecf8427e.css", + assert_equal "/assets/application-d41d8cd98f00b204e9800998ecf8427e.css", sprockets_stylesheet_path(:application) - assert_equal "/stylesheets/style-d41d8cd98f00b204e9800998ecf8427e.css", + assert_equal "/assets/style-d41d8cd98f00b204e9800998ecf8427e.css", sprockets_stylesheet_path("style") - assert_equal "/stylesheets/dir/style-d41d8cd98f00b204e9800998ecf8427e.css", + assert_equal "/assets/dir/style-d41d8cd98f00b204e9800998ecf8427e.css", sprockets_stylesheet_path("dir/style.css") assert_equal "/dir/style.css", sprockets_stylesheet_path("/dir/style.css") @@ -75,19 +78,19 @@ class SprocketsHelperTest < ActionView::TestCase end test "stylesheet link tag" do - assert_equal '<link href="/stylesheets/application-d41d8cd98f00b204e9800998ecf8427e.css" media="screen" rel="stylesheet" type="text/css" />', + assert_equal '<link href="/assets/application-d41d8cd98f00b204e9800998ecf8427e.css" media="screen" rel="stylesheet" type="text/css" />', sprockets_stylesheet_link_tag(:application) - assert_equal '<link href="/stylesheets/style-d41d8cd98f00b204e9800998ecf8427e.css" media="screen" rel="stylesheet" type="text/css" />', + assert_equal '<link href="/assets/style-d41d8cd98f00b204e9800998ecf8427e.css" media="screen" rel="stylesheet" type="text/css" />', sprockets_stylesheet_link_tag("style") - assert_equal '<link href="/stylesheets/style-d41d8cd98f00b204e9800998ecf8427e.css" media="screen" rel="stylesheet" type="text/css" />', + assert_equal '<link href="/assets/style-d41d8cd98f00b204e9800998ecf8427e.css" media="screen" rel="stylesheet" type="text/css" />', sprockets_stylesheet_link_tag("style.css") assert_equal '<link href="http://www.railsapplication.com/style.css" media="screen" rel="stylesheet" type="text/css" />', sprockets_stylesheet_link_tag("http://www.railsapplication.com/style.css") - assert_equal '<link href="/stylesheets/style-d41d8cd98f00b204e9800998ecf8427e.css" media="all" rel="stylesheet" type="text/css" />', + assert_equal '<link href="/assets/style-d41d8cd98f00b204e9800998ecf8427e.css" media="all" rel="stylesheet" type="text/css" />', sprockets_stylesheet_link_tag("style", :media => "all") - assert_equal '<link href="/stylesheets/style-d41d8cd98f00b204e9800998ecf8427e.css" media="print" rel="stylesheet" type="text/css" />', + assert_equal '<link href="/assets/style-d41d8cd98f00b204e9800998ecf8427e.css" media="print" rel="stylesheet" type="text/css" />', sprockets_stylesheet_link_tag("style", :media => "print") end end |