diff options
author | Guillermo Iguaran <guilleiguaran@gmail.com> | 2011-08-31 12:47:33 -0500 |
---|---|---|
committer | Guillermo Iguaran <guilleiguaran@gmail.com> | 2011-08-31 13:12:09 -0500 |
commit | f236e00189b5a6cf0cebac5c275f64d41d73428d (patch) | |
tree | b698934e71ef9d329ccc14fef545239faf9f6362 /actionpack | |
parent | fa04c37f45ca9299a5efb426913488b678c178ce (diff) | |
download | rails-f236e00189b5a6cf0cebac5c275f64d41d73428d.tar.gz rails-f236e00189b5a6cf0cebac5c275f64d41d73428d.tar.bz2 rails-f236e00189b5a6cf0cebac5c275f64d41d73428d.zip |
Backport f443f9cb0c64 to master
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/sprockets/assets.rake | 6 | ||||
-rw-r--r-- | actionpack/lib/sprockets/helpers/rails_helper.rb | 29 | ||||
-rw-r--r-- | actionpack/lib/sprockets/railtie.rb | 6 | ||||
-rw-r--r-- | actionpack/test/template/sprockets_helper_test.rb | 6 |
4 files changed, 17 insertions, 30 deletions
diff --git a/actionpack/lib/sprockets/assets.rake b/actionpack/lib/sprockets/assets.rake index 7ee82ee530..54907abb39 100644 --- a/actionpack/lib/sprockets/assets.rake +++ b/actionpack/lib/sprockets/assets.rake @@ -47,10 +47,8 @@ namespace :assets do env.precompile(*assets) end - if config.assets.manifest - File.open("#{target}/manifest.yml", 'w') do |f| - YAML.dump(manifest, f) - end + File.open("#{target}/manifest.yml", 'w') do |f| + YAML.dump(manifest, f) end end end diff --git a/actionpack/lib/sprockets/helpers/rails_helper.rb b/actionpack/lib/sprockets/helpers/rails_helper.rb index 8e7eb182fd..975dc9e80c 100644 --- a/actionpack/lib/sprockets/helpers/rails_helper.rb +++ b/actionpack/lib/sprockets/helpers/rails_helper.rb @@ -61,7 +61,7 @@ module Sprockets def debug_assets? begin config = Rails.application.config.assets - config.allow_debugging && (config.debug || params[:debug_assets]) + config.compile && (config.debug || params[:debug_assets]) rescue NoMethodError false end @@ -114,22 +114,21 @@ module Sprockets return digest end - if digest.nil? && Rails.application.config.assets.precompile_only - raise AssetNotPrecompiledError - end - - if asset = asset_environment[logical_path] - return asset.digest_path + if Rails.application.config.assets.compile + if asset = asset_environment[logical_path] + return asset.digest_path + end + return logical_path + else + raise AssetNotPrecompiledError.new("#{logical_path} isn't precompiled") end - - logical_path end def rewrite_asset_path(source, dir) if source[0] == ?/ source else - source = digest_for(source) if performing_caching? + source = digest_for(source) if Rails.application.config.assets.digest source = File.join(dir, source) source = "/#{source}" unless source =~ /^\// source @@ -143,16 +142,6 @@ module Sprockets source end end - - def performing_caching? - # When included in Sprockets::Context, we need to ask the - # top-level config as the controller is not available. - if config.action_controller.present? - config.action_controller.perform_caching - else - config.perform_caching - end - end end end end diff --git a/actionpack/lib/sprockets/railtie.rb b/actionpack/lib/sprockets/railtie.rb index 680cb980ff..4adfd000f8 100644 --- a/actionpack/lib/sprockets/railtie.rb +++ b/actionpack/lib/sprockets/railtie.rb @@ -26,10 +26,8 @@ module Sprockets end end - if config.assets.manifest - if File.exist?(path = File.join(Rails.public_path, config.assets.prefix, "manifest.yml")) - config.assets.digests = YAML.load_file(path) - end + if File.exist?(path = File.join(Rails.public_path, config.assets.prefix, "manifest.yml")) + config.assets.digests = YAML.load_file(path) end ActiveSupport.on_load(:action_view) do diff --git a/actionpack/test/template/sprockets_helper_test.rb b/actionpack/test/template/sprockets_helper_test.rb index 6c1f97a44a..ae4cb1f0aa 100644 --- a/actionpack/test/template/sprockets_helper_test.rb +++ b/actionpack/test/template/sprockets_helper_test.rb @@ -30,6 +30,8 @@ class SprocketsHelperTest < ActionView::TestCase @config = config @config.action_controller ||= ActiveSupport::InheritableOptions.new @config.perform_caching = true + @config.assets.digest = true + @config.assets.compile = true end def url_for(*args) @@ -157,7 +159,7 @@ class SprocketsHelperTest < ActionView::TestCase assert_match %r{<script src="/assets/xmlhr-[0-9a-f]+.js\?body=1" type="text/javascript"></script>\n<script src="/assets/application-[0-9a-f]+.js\?body=1" type="text/javascript"></script>}, javascript_include_tag(:application, :debug => true) - @config.assets.allow_debugging = true + @config.assets.compile = true @config.assets.debug = true assert_match %r{<script src="/assets/xmlhr-[0-9a-f]+.js\?body=1" type="text/javascript"></script>\n<script src="/assets/application-[0-9a-f]+.js\?body=1" type="text/javascript"></script>}, javascript_include_tag(:application) @@ -198,7 +200,7 @@ class SprocketsHelperTest < ActionView::TestCase assert_match %r{<link href="/assets/style-[0-9a-f]+.css\?body=1" media="screen" rel="stylesheet" type="text/css" />\n<link href="/assets/application-[0-9a-f]+.css\?body=1" media="screen" rel="stylesheet" type="text/css" />}, stylesheet_link_tag(:application, :debug => true) - @config.assets.allow_debugging = true + @config.assets.compile = true @config.assets.debug = true assert_match %r{<link href="/assets/style-[0-9a-f]+.css\?body=1" media="screen" rel="stylesheet" type="text/css" />\n<link href="/assets/application-[0-9a-f]+.css\?body=1" media="screen" rel="stylesheet" type="text/css" />}, stylesheet_link_tag(:application) |