Skip to content

Commit

Permalink
set env to let rails know we're precompiling
Browse files Browse the repository at this point in the history
  • Loading branch information
hone authored and josevalim committed Sep 22, 2011
1 parent 1de89e5 commit 9d46823
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions actionpack/lib/sprockets/assets.rake
@@ -1,6 +1,9 @@
namespace :assets do namespace :assets do
desc "Compile all the assets named in config.assets.precompile" desc "Compile all the assets named in config.assets.precompile"
task :precompile do 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 # We need to do this dance because RAILS_GROUPS is used
# too early in the boot process and changing here is already too late. # 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? if ENV["RAILS_GROUPS"].to_s.empty? || ENV["RAILS_ENV"].to_s.empty?
Expand Down
9 changes: 9 additions & 0 deletions railties/test/application/assets_test.rb
Expand Up @@ -102,6 +102,15 @@ def app
assert !File.exists?("#{app_path}/public/assets/something.min.css") assert !File.exists?("#{app_path}/public/assets/something.min.css")
end 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 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.assets.digest = true"
add_to_config "config.action_controller.perform_caching = false" add_to_config "config.action_controller.perform_caching = false"
Expand Down

0 comments on commit 9d46823

Please sign in to comment.