1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

generate environment dependent asset digests

If two different environments are configured to use the pipeline, but
one has an extra step (such as compression) then without taking the
environment into account you may end up serving wrong assets
This commit is contained in:
Ilya Grigorik 2011-08-04 23:48:40 -04:00
parent e44efac086
commit ed5c6d254c
2 changed files with 14 additions and 0 deletions

View file

@ -20,6 +20,7 @@ module Sprockets
app.assets = Sprockets::Environment.new(app.root.to_s) do |env|
env.static_root = File.join(app.root.join('public'), config.assets.prefix)
env.logger = ::Rails.logger
env.version = ::Rails.env + '-' + env.version
if config.assets.cache_store != false
env.cache = ActiveSupport::Cache.lookup_store(config.assets.cache_store) || ::Rails.cache

View file

@ -205,4 +205,17 @@ class SprocketsHelperTest < ActionView::TestCase
stubs(:asset_environment).returns(assets)
assert_match %r{/assets/style-[0-9a-f]+.css}, asset_path("style", "css")
end
test "alternate hash based on environment" do
assets = Sprockets::Environment.new
assets.version = 'development'
assets.append_path(FIXTURES.join("sprockets/alternate/stylesheets"))
stubs(:asset_environment).returns(assets)
dev_path = asset_path("style", "css")
assets.version = 'production'
prod_path = asset_path("style", "css")
assert_not_equal prod_path, dev_path
end
end