Add test to make sure the sprockets cache is not shared per environment

This commit is contained in:
Rafael Mendonça França 2016-03-02 14:21:38 -03:00
parent 671e61d867
commit e2f08a1c0a
2 changed files with 22 additions and 2 deletions

View File

@ -116,7 +116,7 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.10.0)
concurrent-ruby (1.0.0)
concurrent-ruby (1.0.1)
connection_pool (2.2.0)
dalli (2.7.6)
dante (0.2.0)
@ -239,7 +239,7 @@ GEM
sprockets (3.5.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.0.2)
sprockets-rails (3.0.4)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)

View File

@ -186,6 +186,26 @@ module ApplicationTests
assert_file_exists("#{app_path}/public/assets/something-*.js")
end
test 'sprockets cache is not shared between environments' do
app_file "app/assets/images/rails.png", "notactuallyapng"
app_file "app/assets/stylesheets/application.css.erb", "<%= asset_path('rails.png') %>"
add_to_env_config 'production', 'config.assets.prefix = "production_assets"'
precompile!
assert_file_exists("#{app_path}/public/assets/application-*.css")
file = Dir["#{app_path}/public/assets/application-*.css"].first
assert_match(/assets\/rails-([0-z]+)\.png/, File.read(file))
precompile! RAILS_ENV: 'production'
assert_file_exists("#{app_path}/public/production_assets/application-*.css")
file = Dir["#{app_path}/public/production_assets/application-*.css"].first
assert_match(/production_assets\/rails-([0-z]+)\.png/, File.read(file))
end
test 'precompile use assets defined in app config and reassigned in app env config' do
add_to_config 'config.assets.precompile = [ "something_manifest.js" ]'
add_to_env_config 'production', 'config.assets.precompile += [ "another_manifest.js" ]'