Skip to content
Browse files

Rails initialization with initialize_on_precompile = false should set…

… assets_dir
  • Loading branch information...
1 parent 5301f6d commit 2e8dac660f097c0fca7e76f76eeff0aea852ee51 @spastorino spastorino committed
Showing with 10 additions and 1 deletion.
  1. +4 −1 actionpack/lib/action_controller/railtie.rb
  2. +6 −0 railties/test/application/assets_test.rb
View
5 actionpack/lib/action_controller/railtie.rb
@@ -17,11 +17,14 @@ class Railtie < Rails::Railtie
ActiveSupport.on_load(:action_controller) { self.cache_store ||= RAILS_CACHE }
end
+ initializer "action_controller.assets_config", :group => :all do |app|
+ app.config.action_controller.assets_dir ||= app.config.paths["public"].first
+ end
+
initializer "action_controller.set_configs" do |app|
paths = app.config.paths
options = app.config.action_controller
- options.assets_dir ||= paths["public"].first
options.javascripts_dir ||= paths["public/javascripts"].first
options.stylesheets_dir ||= paths["public/stylesheets"].first
options.page_cache_directory ||= paths["public"].first
View
6 railties/test/application/assets_test.rb
@@ -427,6 +427,12 @@ class ::PostsController < ActionController::Base ; end
assert_equal "NoPost;\n", File.read("#{app_path}/public/assets/application.js")
end
+ test "initialization on the assets group should set assets_dir" do
+ require "#{app_path}/config/application"
+ Rails.application.initialize!(:assets)
+ assert_not_nil Rails.application.config.action_controller.assets_dir
+ end
+
test "enhancements to assets:precompile should only run once" do
app_file "lib/tasks/enhance.rake", "Rake::Task['assets:precompile'].enhance { puts 'enhancement' }"
output = precompile!

0 comments on commit 2e8dac6

Please sign in to comment.
Something went wrong with that request. Please try again.