diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2011-09-13 16:40:53 -0700 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2011-09-13 16:40:53 -0700 |
commit | 410b0ec1b712ce34f0fafb6505876d21e8007db7 (patch) | |
tree | 358a8ebd476cb626f3fbad0e15473ff9522c6d40 | |
parent | 3b8a7cf2a7b2ffce671ca7f655de736c1054edbc (diff) | |
parent | a89d39ec889c2658120e508bd182de7be3ccdcc9 (diff) | |
download | rails-410b0ec1b712ce34f0fafb6505876d21e8007db7.tar.gz rails-410b0ec1b712ce34f0fafb6505876d21e8007db7.tar.bz2 rails-410b0ec1b712ce34f0fafb6505876d21e8007db7.zip |
Merge pull request #3011 from guilleiguaran/disable-sprockets-server
Don't mount Sprockets if config.assets.compile is disabled
-rw-r--r-- | actionpack/lib/sprockets/railtie.rb | 6 | ||||
-rw-r--r-- | railties/test/application/assets_test.rb | 14 |
2 files changed, 17 insertions, 3 deletions
diff --git a/actionpack/lib/sprockets/railtie.rb b/actionpack/lib/sprockets/railtie.rb index dc991636a1..f05d835554 100644 --- a/actionpack/lib/sprockets/railtie.rb +++ b/actionpack/lib/sprockets/railtie.rb @@ -67,8 +67,10 @@ module Sprockets end end - app.routes.prepend do - mount app.assets => config.assets.prefix + if config.assets.compile + app.routes.prepend do + mount app.assets => config.assets.prefix + end end if config.assets.digest diff --git a/railties/test/application/assets_test.rb b/railties/test/application/assets_test.rb index 9245532e17..9b141ccbac 100644 --- a/railties/test/application/assets_test.rb +++ b/railties/test/application/assets_test.rb @@ -38,7 +38,7 @@ module ApplicationTests test "assets do not require compressors until it is used" do app_file "app/assets/javascripts/demo.js.erb", "<%= :alert %>();" - add_to_config "config.assets.compile = true" + app_file "config/initializers/compile.rb", "Rails.application.config.assets.compile = true" ENV["RAILS_ENV"] = "production" require "#{app_path}/config/environment" @@ -178,6 +178,7 @@ module ApplicationTests test "assets do not require any assets group gem when manifest file is present" do app_file "app/assets/javascripts/application.js", "alert();" + app_file "config/initializers/serve_static_assets.rb", "Rails.application.config.serve_static_assets = true" ENV["RAILS_ENV"] = "production" capture(:stdout) do @@ -314,6 +315,17 @@ module ApplicationTests assert_equal 0, files.length, "Expected no assets, but found #{files.join(', ')}" end + test "assets routes are not drawn when compilation is disabled" do + app_file "app/assets/javascripts/demo.js.erb", "<%= :alert %>();" + add_to_config "config.assets.compile = false" + + ENV["RAILS_ENV"] = "production" + require "#{app_path}/config/environment" + + get "/assets/demo.js" + assert_equal 404, last_response.status + end + test "does not stream session cookies back" do app_file "app/assets/javascripts/demo.js.erb", "<%= :alert %>();" |