Don't mount Sprockets at config.assets.prefix if config.assets.compile is false.

This commit is contained in:
Mark J. Titorenko
2011-09-06 10:34:24 +01:00
committed by Guillermo Iguaran
parent 3b8a7cf2a7
commit f22407dd34
2 changed files with 16 additions and 2 deletions

View File

@@ -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

View File

@@ -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 %>();"
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 %>();"