aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/lib/sprockets/assets.rake3
-rw-r--r--railties/test/application/assets_test.rb9
2 files changed, 12 insertions, 0 deletions
diff --git a/actionpack/lib/sprockets/assets.rake b/actionpack/lib/sprockets/assets.rake
index e38ac6b489..7241671db0 100644
--- a/actionpack/lib/sprockets/assets.rake
+++ b/actionpack/lib/sprockets/assets.rake
@@ -1,6 +1,9 @@
namespace :assets do
desc "Compile all the assets named in config.assets.precompile"
task :precompile do
+ # let rails know we're precompiling assets
+ ENV["RAILS_ASSETS_PRECOMPILE"] = 'true'
+
# We need to do this dance because RAILS_GROUPS is used
# too early in the boot process and changing here is already too late.
if ENV["RAILS_GROUPS"].to_s.empty? || ENV["RAILS_ENV"].to_s.empty?
diff --git a/railties/test/application/assets_test.rb b/railties/test/application/assets_test.rb
index a62ef1e70e..c4a24f0f73 100644
--- a/railties/test/application/assets_test.rb
+++ b/railties/test/application/assets_test.rb
@@ -102,6 +102,15 @@ module ApplicationTests
assert !File.exists?("#{app_path}/public/assets/something.min.css")
end
+ test "precompile sets flag notifying rails its precompiling" do
+ compile = <<COMPILE
+raise "ENV RAILS_ASSETS_PRECOMPILE not set" unless ENV["RAILS_ASSETS_PRECOMPILE"]
+COMPILE
+ app_file "config/initializers/compile.rb", compile
+ Dir.chdir(app_path){ `bundle exec rake assets:precompile` }
+ assert $?.success?
+ end
+
test "asset pipeline should use a Sprockets::Index when config.assets.digest is true" do
add_to_config "config.assets.digest = true"
add_to_config "config.action_controller.perform_caching = false"