Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Don't mount Sprockets at config.assets.prefix if config.assets.compil…

…e is false.
  • Loading branch information...
commit f22407dd34024886edd8a8f618dc0b19152776a0 1 parent 3b8a7cf
@mjtko mjtko authored guilleiguaran committed
View
6 actionpack/lib/sprockets/railtie.rb
@@ -67,8 +67,10 @@ class Railtie < ::Rails::Railtie
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
View
12 railties/test/application/assets_test.rb
@@ -178,6 +178,7 @@ def app
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 @@ class ::PostsController < ActionController::Base ; end
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 %>();"
+ app_file "config/initializers/compile.rb", "Rails.application.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 %>();"
Please sign in to comment.
Something went wrong with that request. Please try again.