diff options
author | Guillermo Iguaran <guilleiguaran@gmail.com> | 2011-08-31 12:47:33 -0500 |
---|---|---|
committer | Guillermo Iguaran <guilleiguaran@gmail.com> | 2011-08-31 13:12:09 -0500 |
commit | f236e00189b5a6cf0cebac5c275f64d41d73428d (patch) | |
tree | b698934e71ef9d329ccc14fef545239faf9f6362 /railties/test/application | |
parent | fa04c37f45ca9299a5efb426913488b678c178ce (diff) | |
download | rails-f236e00189b5a6cf0cebac5c275f64d41d73428d.tar.gz rails-f236e00189b5a6cf0cebac5c275f64d41d73428d.tar.bz2 rails-f236e00189b5a6cf0cebac5c275f64d41d73428d.zip |
Backport f443f9cb0c64 to master
Diffstat (limited to 'railties/test/application')
-rw-r--r-- | railties/test/application/assets_test.rb | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/railties/test/application/assets_test.rb b/railties/test/application/assets_test.rb index 9df10e84d8..a4d7fc92f5 100644 --- a/railties/test/application/assets_test.rb +++ b/railties/test/application/assets_test.rb @@ -37,6 +37,8 @@ module ApplicationTests test "assets do not require compressors until it is used" do app_file "app/assets/javascripts/demo.js.erb", "<%= :alert %>();" + app_file "config/initializers/compile.rb", "Rails.application.config.assets.compile = true" + ENV["RAILS_ENV"] = "production" require "#{app_path}/config/environment" @@ -62,18 +64,7 @@ module ApplicationTests end end - test "precompile don't create a manifest file when manifest option is off" do - app_file "app/assets/javascripts/application.js", "alert();" - app_file "config/initializers/manifest.rb", "Rails.application.config.assets.manifest = false" - - capture(:stdout) do - Dir.chdir(app_path){ `bundle exec rake assets:precompile` } - end - - assert !File.exist?("#{app_path}/public/assets/manifest.yml") - end - - test "precompile creates a manifest file with all the assets listed when manifest option is on" do + test "precompile creates a manifest file with all the assets listed" do app_file "app/assets/stylesheets/application.css.erb", "<%= asset_path('rails.png') %>" app_file "app/assets/javascripts/application.js", "alert();" @@ -88,7 +79,7 @@ module ApplicationTests assert_match /application-([0-z]+)\.css/, assets["application.css"] end - test "assets do not require any assets group gem when manifest option is on and manifest file is present" do + test "assets do not require any assets group gem when manifest file is present" do app_file "app/assets/javascripts/application.js", "alert();" ENV["RAILS_ENV"] = "production" @@ -108,10 +99,8 @@ module ApplicationTests assert !defined?(Uglifier) end - test "assets raise AssetNotPrecompiledError if config.assets.precompile_only is on and file isn't precompiled" do - app_file "app/assets/javascripts/app.js", "alert();" + test "assets raise AssetNotPrecompiledError when manifest file is present and requested file isn't precompiled" do app_file "app/views/posts/index.html.erb", "<%= javascript_include_tag 'app' %>" - app_file "config/initializers/precompile_only.rb", "Rails.application.config.assets.precompile_only = true" app_file "config/routes.rb", <<-RUBY AppTemplate::Application.routes.draw do @@ -120,15 +109,25 @@ module ApplicationTests RUBY ENV["RAILS_ENV"] = "production" + capture(:stdout) do + Dir.chdir(app_path){ `bundle exec rake assets:precompile` } + end + + # Create file after of precompile + app_file "app/assets/javascripts/app.js", "alert();" + require "#{app_path}/config/environment" class ::PostsController < ActionController::Base ; end get '/posts' assert_match /AssetNotPrecompiledError/, last_response.body + assert_match /app.js isn't precompiled/, last_response.body end test "precompile appends the md5 hash to files referenced with asset_path and run in the provided RAILS_ENV" do app_file "app/assets/stylesheets/application.css.erb", "<%= asset_path('rails.png') %>" + # digest is default in false, we must enable it for test environment + app_file "config/initializers/compile.rb", "Rails.application.config.assets.digest = true" # capture(:stdout) do Dir.chdir(app_path){ `bundle exec rake assets:precompile RAILS_ENV=test` } @@ -139,6 +138,7 @@ module ApplicationTests test "precompile appends the md5 hash to files referenced with asset_path and run in production as default even using RAILS_GROUPS=assets" do app_file "app/assets/stylesheets/application.css.erb", "<%= asset_path('rails.png') %>" + app_file "config/initializers/compile.rb", "Rails.application.config.assets.compile = true" ENV["RAILS_ENV"] = nil capture(:stdout) do |