From dffdd829930e664cef522f34730d5987be348596 Mon Sep 17 00:00:00 2001 From: Guillermo Iguaran Date: Mon, 29 Aug 2011 16:28:11 -0500 Subject: Read digests of assets from manifest.yml if config.assets.manifest is on --- actionpack/lib/sprockets/assets.rake | 10 +++- actionpack/lib/sprockets/helpers/rails_helper.rb | 17 +++++- actionpack/lib/sprockets/railtie.rb | 6 ++ railties/lib/rails/application/configuration.rb | 9 +-- .../rails/app/templates/config/application.rb | 4 ++ railties/test/application/assets_test.rb | 65 ++++++++++++++++++++++ 6 files changed, 105 insertions(+), 6 deletions(-) diff --git a/actionpack/lib/sprockets/assets.rake b/actionpack/lib/sprockets/assets.rake index 5698f22080..7ee82ee530 100644 --- a/actionpack/lib/sprockets/assets.rake +++ b/actionpack/lib/sprockets/assets.rake @@ -19,7 +19,8 @@ namespace :assets do config = Rails.application.config env = Rails.application.assets - target = Rails.root.join("public#{config.assets.prefix}") + target = Pathname.new(File.join(Rails.public_path, config.assets.prefix)) + manifest = {} if env.respond_to?(:each_logical_path) config.assets.precompile.each do |path| @@ -31,6 +32,7 @@ namespace :assets do end if asset = env.find_asset(logical_path) + manifest[logical_path] = asset.digest_path filename = target.join(asset.digest_path) mkdir_p filename.dirname asset.write_to(filename) @@ -44,6 +46,12 @@ namespace :assets do assets << {:to => target} env.precompile(*assets) end + + if config.assets.manifest + File.open("#{target}/manifest.yml", 'w') do |f| + YAML.dump(manifest, f) + end + end end end diff --git a/actionpack/lib/sprockets/helpers/rails_helper.rb b/actionpack/lib/sprockets/helpers/rails_helper.rb index 062aa4dae5..8e7eb182fd 100644 --- a/actionpack/lib/sprockets/helpers/rails_helper.rb +++ b/actionpack/lib/sprockets/helpers/rails_helper.rb @@ -14,6 +14,7 @@ module Sprockets paths = RailsHelper::AssetPaths.new(config, controller) paths.asset_environment = asset_environment paths.asset_prefix = asset_prefix + paths.asset_digests = asset_digests paths end end @@ -76,6 +77,10 @@ module Sprockets Rails.application.config.assets.prefix end + def asset_digests + Rails.application.config.assets.digests + end + # Override to specify an alternative asset environment for asset # path generation. The environment should already have been mounted # at the prefix returned by +asset_prefix+. @@ -84,7 +89,9 @@ module Sprockets end class AssetPaths < ::ActionView::AssetPaths #:nodoc: - attr_accessor :asset_environment, :asset_prefix + attr_accessor :asset_environment, :asset_prefix, :asset_digests + + class AssetNotPrecompiledError < StandardError; end def compute_public_path(source, dir, ext=nil, include_host=true, protocol=nil) super(source, asset_prefix, ext, include_host, protocol) @@ -103,6 +110,14 @@ module Sprockets end def digest_for(logical_path) + if asset_digests && (digest = asset_digests[logical_path]) + 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 end diff --git a/actionpack/lib/sprockets/railtie.rb b/actionpack/lib/sprockets/railtie.rb index c21bf57935..680cb980ff 100644 --- a/actionpack/lib/sprockets/railtie.rb +++ b/actionpack/lib/sprockets/railtie.rb @@ -26,6 +26,12 @@ 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 + end + ActiveSupport.on_load(:action_view) do include ::Sprockets::Helpers::RailsHelper diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index 5d7bd3282d..7f4db0a19f 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -42,10 +42,11 @@ module Rails @assets.version = '' @assets.debug = false @assets.allow_debugging = false - - @assets.cache_store = [ :file_store, "#{root}/tmp/cache/assets/" ] - @assets.js_compressor = nil - @assets.css_compressor = nil + @assets.manifest = true + @assets.precompile_only = false + @assets.cache_store = [ :file_store, "#{root}/tmp/cache/assets/" ] + @assets.js_compressor = nil + @assets.css_compressor = nil end def compiled_asset_path diff --git a/railties/lib/rails/generators/rails/app/templates/config/application.rb b/railties/lib/rails/generators/rails/app/templates/config/application.rb index 3891829150..30a75200cb 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/application.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/application.rb @@ -52,6 +52,10 @@ module <%= app_const_base %> <% unless options.skip_sprockets? -%> # Enable the asset pipeline config.assets.enabled = true + + # Create a manifest with the hashes of your assets when you run "rake assets:precompile". + # Use this if you don't have a JavaScript engine in your production servers + config.assets.manifest = true <% end -%> end end diff --git a/railties/test/application/assets_test.rb b/railties/test/application/assets_test.rb index a8d1382e94..9df10e84d8 100644 --- a/railties/test/application/assets_test.rb +++ b/railties/test/application/assets_test.rb @@ -62,6 +62,71 @@ module ApplicationTests end end + test "precompile don't create a manifest file when manifest option is off" do + app_file "app/assets/javascripts/application.js", "alert();" + app_file "config/initializers/manifest.rb", "Rails.application.config.assets.manifest = false" + + capture(:stdout) do + Dir.chdir(app_path){ `bundle exec rake assets:precompile` } + end + + assert !File.exist?("#{app_path}/public/assets/manifest.yml") + end + + test "precompile creates a manifest file with all the assets listed when manifest option is on" do + app_file "app/assets/stylesheets/application.css.erb", "<%= asset_path('rails.png') %>" + app_file "app/assets/javascripts/application.js", "alert();" + + capture(:stdout) do + Dir.chdir(app_path){ `bundle exec rake assets:precompile` } + end + + manifest = "#{app_path}/public/assets/manifest.yml" + + assets = YAML.load_file(manifest) + assert_match /application-([0-z]+)\.js/, assets["application.js"] + assert_match /application-([0-z]+)\.css/, assets["application.css"] + end + + test "assets do not require any assets group gem when manifest option is on and manifest file is present" do + app_file "app/assets/javascripts/application.js", "alert();" + + ENV["RAILS_ENV"] = "production" + capture(:stdout) do + Dir.chdir(app_path){ `bundle exec rake assets:precompile` } + end + manifest = "#{app_path}/public/assets/manifest.yml" + assets = YAML.load_file(manifest) + asset_path = assets["application.js"] + + require "#{app_path}/config/environment" + + # Checking if Uglifier is defined we can know if Sprockets was reached or not + assert !defined?(Uglifier) + get "/assets/#{asset_path}" + assert_match "alert()", last_response.body + assert !defined?(Uglifier) + end + + test "assets raise AssetNotPrecompiledError if config.assets.precompile_only is on and file isn't precompiled" do + app_file "app/assets/javascripts/app.js", "alert();" + app_file "app/views/posts/index.html.erb", "<%= javascript_include_tag 'app' %>" + app_file "config/initializers/precompile_only.rb", "Rails.application.config.assets.precompile_only = true" + + app_file "config/routes.rb", <<-RUBY + AppTemplate::Application.routes.draw do + match '/posts', :to => "posts#index" + end + RUBY + + ENV["RAILS_ENV"] = "production" + require "#{app_path}/config/environment" + class ::PostsController < ActionController::Base ; end + + get '/posts' + assert_match /AssetNotPrecompiledError/, last_response.body + end + test "precompile appends the md5 hash to files referenced with asset_path and run in the provided RAILS_ENV" do app_file "app/assets/stylesheets/application.css.erb", "<%= asset_path('rails.png') %>" -- cgit v1.2.3 From fa04c37f45ca9299a5efb426913488b678c178ce Mon Sep 17 00:00:00 2001 From: Guillermo Iguaran Date: Wed, 31 Aug 2011 12:42:54 -0500 Subject: Backport b0f30631662 to master --- .../lib/rails/generators/rails/app/templates/config/application.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/railties/lib/rails/generators/rails/app/templates/config/application.rb b/railties/lib/rails/generators/rails/app/templates/config/application.rb index 30a75200cb..13fbe9e526 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/application.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/application.rb @@ -53,9 +53,8 @@ module <%= app_const_base %> # Enable the asset pipeline config.assets.enabled = true - # Create a manifest with the hashes of your assets when you run "rake assets:precompile". - # Use this if you don't have a JavaScript engine in your production servers - config.assets.manifest = true + # Version of your assets, change this if you want to expire all your assets + config.assets.version = '1.0' <% end -%> end end -- cgit v1.2.3 From f236e00189b5a6cf0cebac5c275f64d41d73428d Mon Sep 17 00:00:00 2001 From: Guillermo Iguaran Date: Wed, 31 Aug 2011 12:47:33 -0500 Subject: Backport f443f9cb0c64 to master --- actionpack/lib/sprockets/assets.rake | 6 ++-- actionpack/lib/sprockets/helpers/rails_helper.rb | 29 ++++++-------------- actionpack/lib/sprockets/railtie.rb | 6 ++-- actionpack/test/template/sprockets_helper_test.rb | 6 ++-- railties/lib/rails/application/configuration.rb | 5 ++-- .../config/environments/development.rb.tt | 3 -- .../templates/config/environments/production.rb.tt | 6 ++++ railties/test/application/assets_test.rb | 32 +++++++++++----------- 8 files changed, 41 insertions(+), 52 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{\n}, javascript_include_tag(:application, :debug => true) - @config.assets.allow_debugging = true + @config.assets.compile = true @config.assets.debug = true assert_match %r{\n}, javascript_include_tag(:application) @@ -198,7 +200,7 @@ class SprocketsHelperTest < ActionView::TestCase assert_match %r{\n}, stylesheet_link_tag(:application, :debug => true) - @config.assets.allow_debugging = true + @config.assets.compile = true @config.assets.debug = true assert_match %r{\n}, stylesheet_link_tag(:application) diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index 7f4db0a19f..85e0cd5061 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -41,9 +41,8 @@ module Rails @assets.prefix = "/assets" @assets.version = '' @assets.debug = false - @assets.allow_debugging = false - @assets.manifest = true - @assets.precompile_only = false + @assets.compile = true + @assets.digest = false @assets.cache_store = [ :file_store, "#{root}/tmp/cache/assets/" ] @assets.js_compressor = nil @assets.css_compressor = nil diff --git a/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt index 33f9939ffe..47078e3af9 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +++ b/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt @@ -30,9 +30,6 @@ # Do not compress assets config.assets.compress = false - # Allow pass debug_assets=true as a query parameter to load pages with unpackaged assets - config.assets.allow_debugging = true - # Expands the lines which load the assets config.assets.debug = true end diff --git a/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt index de56d47688..b4754cfc6d 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +++ b/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt @@ -14,6 +14,12 @@ # Compress JavaScripts and CSS config.assets.compress = true + # Don't fallback to assets pipeline if a precompiled asset is missed + config.assets.compile = false + + # Generate digests for assets URLs + config.assets.digest = true + # Specifies the header that your server uses for sending files # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx diff --git a/railties/test/application/assets_test.rb b/railties/test/application/assets_test.rb index 9df10e84d8..a4d7fc92f5 100644 --- a/railties/test/application/assets_test.rb +++ b/railties/test/application/assets_test.rb @@ -37,6 +37,8 @@ module ApplicationTests test "assets do not require compressors until it is used" do app_file "app/assets/javascripts/demo.js.erb", "<%= :alert %>();" + app_file "config/initializers/compile.rb", "Rails.application.config.assets.compile = true" + ENV["RAILS_ENV"] = "production" require "#{app_path}/config/environment" @@ -62,18 +64,7 @@ module ApplicationTests end end - test "precompile don't create a manifest file when manifest option is off" do - app_file "app/assets/javascripts/application.js", "alert();" - app_file "config/initializers/manifest.rb", "Rails.application.config.assets.manifest = false" - - capture(:stdout) do - Dir.chdir(app_path){ `bundle exec rake assets:precompile` } - end - - assert !File.exist?("#{app_path}/public/assets/manifest.yml") - end - - test "precompile creates a manifest file with all the assets listed when manifest option is on" do + test "precompile creates a manifest file with all the assets listed" do app_file "app/assets/stylesheets/application.css.erb", "<%= asset_path('rails.png') %>" app_file "app/assets/javascripts/application.js", "alert();" @@ -88,7 +79,7 @@ module ApplicationTests assert_match /application-([0-z]+)\.css/, assets["application.css"] end - test "assets do not require any assets group gem when manifest option is on and manifest file is present" do + test "assets do not require any assets group gem when manifest file is present" do app_file "app/assets/javascripts/application.js", "alert();" ENV["RAILS_ENV"] = "production" @@ -108,10 +99,8 @@ module ApplicationTests assert !defined?(Uglifier) end - test "assets raise AssetNotPrecompiledError if config.assets.precompile_only is on and file isn't precompiled" do - app_file "app/assets/javascripts/app.js", "alert();" + test "assets raise AssetNotPrecompiledError when manifest file is present and requested file isn't precompiled" do app_file "app/views/posts/index.html.erb", "<%= javascript_include_tag 'app' %>" - app_file "config/initializers/precompile_only.rb", "Rails.application.config.assets.precompile_only = true" app_file "config/routes.rb", <<-RUBY AppTemplate::Application.routes.draw do @@ -120,15 +109,25 @@ module ApplicationTests RUBY ENV["RAILS_ENV"] = "production" + capture(:stdout) do + Dir.chdir(app_path){ `bundle exec rake assets:precompile` } + end + + # Create file after of precompile + app_file "app/assets/javascripts/app.js", "alert();" + require "#{app_path}/config/environment" class ::PostsController < ActionController::Base ; end get '/posts' assert_match /AssetNotPrecompiledError/, last_response.body + assert_match /app.js isn't precompiled/, last_response.body end test "precompile appends the md5 hash to files referenced with asset_path and run in the provided RAILS_ENV" do app_file "app/assets/stylesheets/application.css.erb", "<%= asset_path('rails.png') %>" + # digest is default in false, we must enable it for test environment + app_file "config/initializers/compile.rb", "Rails.application.config.assets.digest = true" # capture(:stdout) do Dir.chdir(app_path){ `bundle exec rake assets:precompile RAILS_ENV=test` } @@ -139,6 +138,7 @@ module ApplicationTests test "precompile appends the md5 hash to files referenced with asset_path and run in production as default even using RAILS_GROUPS=assets" do app_file "app/assets/stylesheets/application.css.erb", "<%= asset_path('rails.png') %>" + app_file "config/initializers/compile.rb", "Rails.application.config.assets.compile = true" ENV["RAILS_ENV"] = nil capture(:stdout) do -- cgit v1.2.3 From d0b3937b8fe2cbc4385e843d47249af3e7181a83 Mon Sep 17 00:00:00 2001 From: Guillermo Iguaran Date: Tue, 30 Aug 2011 16:30:53 -0500 Subject: Set default location of manifest with config.assets.manifest --- actionpack/lib/sprockets/assets.rake | 3 ++- actionpack/lib/sprockets/railtie.rb | 8 +++++++- railties/lib/rails/application/configuration.rb | 1 + .../app/templates/config/environments/production.rb.tt | 3 +++ railties/test/application/assets_test.rb | 17 +++++++++++++++++ 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/actionpack/lib/sprockets/assets.rake b/actionpack/lib/sprockets/assets.rake index 54907abb39..6f38ece0c3 100644 --- a/actionpack/lib/sprockets/assets.rake +++ b/actionpack/lib/sprockets/assets.rake @@ -21,6 +21,7 @@ namespace :assets do env = Rails.application.assets target = Pathname.new(File.join(Rails.public_path, config.assets.prefix)) manifest = {} + manifest_path = config.assets.manifest || target if env.respond_to?(:each_logical_path) config.assets.precompile.each do |path| @@ -47,7 +48,7 @@ namespace :assets do env.precompile(*assets) end - File.open("#{target}/manifest.yml", 'w') do |f| + File.open("#{manifest_path}/manifest.yml", 'w') do |f| YAML.dump(manifest, f) end end diff --git a/actionpack/lib/sprockets/railtie.rb b/actionpack/lib/sprockets/railtie.rb index 4adfd000f8..7927b7bc2c 100644 --- a/actionpack/lib/sprockets/railtie.rb +++ b/actionpack/lib/sprockets/railtie.rb @@ -26,7 +26,13 @@ module Sprockets end end - if File.exist?(path = File.join(Rails.public_path, config.assets.prefix, "manifest.yml")) + if config.assets.manifest + path = File.join(config.assets.manifest, "manifest.yml") + else + path = File.join(Rails.public_path, config.assets.prefix, "manifest.yml") + end + + if File.exist?(path) config.assets.digests = YAML.load_file(path) end diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index 85e0cd5061..fa7e3b820b 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -43,6 +43,7 @@ module Rails @assets.debug = false @assets.compile = true @assets.digest = false + @assets.manifest = "#{root}/public#{@assets.prefix}" @assets.cache_store = [ :file_store, "#{root}/tmp/cache/assets/" ] @assets.js_compressor = nil @assets.css_compressor = nil diff --git a/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt index b4754cfc6d..64e2c09467 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +++ b/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt @@ -20,6 +20,9 @@ # Generate digests for assets URLs config.assets.digest = true + # Defaults to Rails.root.join("public/assets") + # config.assets.manifest = YOUR_PATH + # Specifies the header that your server uses for sending files # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx diff --git a/railties/test/application/assets_test.rb b/railties/test/application/assets_test.rb index a4d7fc92f5..ccadf0b2c0 100644 --- a/railties/test/application/assets_test.rb +++ b/railties/test/application/assets_test.rb @@ -79,6 +79,23 @@ module ApplicationTests assert_match /application-([0-z]+)\.css/, assets["application.css"] end + test "precompile creates a manifest file in a custom path with all the assets listed" do + app_file "app/assets/stylesheets/application.css.erb", "<%= asset_path('rails.png') %>" + app_file "app/assets/javascripts/application.js", "alert();" + FileUtils.mkdir "#{app_path}/shared" + app_file "config/initializers/manifest.rb", "Rails.application.config.assets.manifest = '#{app_path}/shared'" + + capture(:stdout) do + Dir.chdir(app_path){ `bundle exec rake assets:precompile` } + end + + manifest = "#{app_path}/shared/manifest.yml" + + assets = YAML.load_file(manifest) + assert_match /application-([0-z]+)\.js/, assets["application.js"] + assert_match /application-([0-z]+)\.css/, assets["application.css"] + end + test "assets do not require any assets group gem when manifest file is present" do app_file "app/assets/javascripts/application.js", "alert();" -- cgit v1.2.3 From 87074600d3f7909bce7884c4588aab83f1b3a2d1 Mon Sep 17 00:00:00 2001 From: Guillermo Iguaran Date: Wed, 31 Aug 2011 13:09:35 -0500 Subject: Fix asset debugging tests to reflect last changes in 3-1-stable --- railties/test/application/asset_debugging_test.rb | 27 +++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/railties/test/application/asset_debugging_test.rb b/railties/test/application/asset_debugging_test.rb index 38e1e21d17..707abe7191 100644 --- a/railties/test/application/asset_debugging_test.rb +++ b/railties/test/application/asset_debugging_test.rb @@ -33,24 +33,33 @@ module ApplicationTests teardown_app end - test "assets are concatenated when debug is off and allow_debugging is off either if debug_assets param is provided" do - # config.assets.debug and config.assets.allow_debugging are false for production environment + test "assets are concatenated when debug is off and compile is off either if debug_assets param is provided" do + # config.assets.debug and config.assets.compile are false for production environment + ENV["RAILS_ENV"] = "production" + capture(:stdout) do + Dir.chdir(app_path){ `bundle exec rake assets:precompile` } + end require "#{app_path}/config/environment" - # the debug_assets params isn't used if allow_debugging is off + class ::PostsController < ActionController::Base ; end + + # the debug_assets params isn't used if compile is off get '/posts?debug_assets=true' - assert_match %r{}, last_response.body - assert_no_match %r{}, last_response.body + assert_match /}, last_response.body - assert_match %r{}, last_response.body + assert_match /