Permalink
Browse files

#10428: Added tests for config.assets.precompile

Tests for bug in sprocket-rails:
  do not use value of configuration options
  which changed after environment loaded
  • Loading branch information...
1 parent 7c69a82 commit 9da48a998c6f8102bfc83b80e65edbcc542036c6 @pftg pftg committed May 8, 2013
Showing with 23 additions and 0 deletions.
  1. +23 −0 railties/test/application/assets_test.rb
@@ -165,6 +165,29 @@ class User < ActiveRecord::Base; end
assert_file_exists("#{app_path}/public/assets/something-*.js")
end
+ test 'precompile use assets defined in app env config' do
+ add_to_env_config 'production', 'config.assets.precompile = [ "something.js" ]'
+
+ app_file 'app/assets/javascripts/something.js.erb', 'alert();'
+
+ precompile! 'RAILS_ENV=production'
+
+ assert_file_exists("#{app_path}/public/assets/something-*.js")
+ end
+
+ test 'precompile use assets defined in app config and reassigned in app env config' do
+ add_to_config 'config.assets.precompile = [ "something.js" ]'
+ add_to_env_config 'production', 'config.assets.precompile += [ "another.js" ]'
+
+ app_file 'app/assets/javascripts/something.js.erb', 'alert();'
+ app_file 'app/assets/javascripts/another.js.erb', 'alert();'
+
+ precompile! 'RAILS_ENV=production'
+
+ assert_file_exists("#{app_path}/public/assets/something-*.js")
+ assert_file_exists("#{app_path}/public/assets/another-*.js")
+ 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"

0 comments on commit 9da48a9

Please sign in to comment.