Permalink
Browse files

Merge branch 'asset_hash_should_depend_on_env'

  • Loading branch information...
2 parents 050c151 + ed5c6d2 commit fe55f5e5818698ff627d032f12a2cbbffdd7e739 @igrigorik igrigorik committed Aug 5, 2011
Showing with 14 additions and 0 deletions.
  1. +1 −0 actionpack/lib/sprockets/railtie.rb
  2. +13 −0 actionpack/test/template/sprockets_helper_test.rb
@@ -20,6 +20,7 @@ class Railtie < ::Rails::Railtie
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
@@ -205,4 +205,17 @@ def url_for(*args)
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

0 comments on commit fe55f5e

Please sign in to comment.