aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorIlya Grigorik <ilya@igvita.com>2011-08-04 23:55:31 -0400
committerIlya Grigorik <ilya@igvita.com>2011-08-04 23:55:31 -0400
commitfe55f5e5818698ff627d032f12a2cbbffdd7e739 (patch)
tree57009382e87c73bacc5a77929e5ceafd5605060a /actionpack
parent050c1510b6041a0de21899de1c08d2b816ec0e66 (diff)
parented5c6d254c9ef5d44a11159561fddde7a3033874 (diff)
downloadrails-fe55f5e5818698ff627d032f12a2cbbffdd7e739.tar.gz
rails-fe55f5e5818698ff627d032f12a2cbbffdd7e739.tar.bz2
rails-fe55f5e5818698ff627d032f12a2cbbffdd7e739.zip
Merge branch 'asset_hash_should_depend_on_env'
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/sprockets/railtie.rb1
-rw-r--r--actionpack/test/template/sprockets_helper_test.rb13
2 files changed, 14 insertions, 0 deletions
diff --git a/actionpack/lib/sprockets/railtie.rb b/actionpack/lib/sprockets/railtie.rb
index c8438e6043..0c2eb5075b 100644
--- a/actionpack/lib/sprockets/railtie.rb
+++ b/actionpack/lib/sprockets/railtie.rb
@@ -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
diff --git a/actionpack/test/template/sprockets_helper_test.rb b/actionpack/test/template/sprockets_helper_test.rb
index f4b5344d63..dfa635335e 100644
--- a/actionpack/test/template/sprockets_helper_test.rb
+++ b/actionpack/test/template/sprockets_helper_test.rb
@@ -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