diff options
author | Xavier Noria <fxn@hashref.com> | 2010-07-30 02:35:24 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2010-07-30 02:35:24 +0200 |
commit | ccd45618ed9a629c9535a5ff84ef5c238befa4ab (patch) | |
tree | 0a582bf695dce01240762d2b8516efde43bc3515 /activesupport/test/caching_test.rb | |
parent | 3c3ff1377d17b584dd14d85c7cecab59ddff2679 (diff) | |
parent | 755af497555fde16db86f7e51f6462b0aca79b49 (diff) | |
download | rails-ccd45618ed9a629c9535a5ff84ef5c238befa4ab.tar.gz rails-ccd45618ed9a629c9535a5ff84ef5c238befa4ab.tar.bz2 rails-ccd45618ed9a629c9535a5ff84ef5c238befa4ab.zip |
Merge remote branch 'rails/master'
Diffstat (limited to 'activesupport/test/caching_test.rb')
-rw-r--r-- | activesupport/test/caching_test.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/activesupport/test/caching_test.rb b/activesupport/test/caching_test.rb index 212c1f82a8..b79a7bbaec 100644 --- a/activesupport/test/caching_test.rb +++ b/activesupport/test/caching_test.rb @@ -7,6 +7,49 @@ class CacheKeyTest < ActiveSupport::TestCase assert_equal '1/2/true', ActiveSupport::Cache.expand_cache_key([1, '2', true]) assert_equal 'name/1/2/true', ActiveSupport::Cache.expand_cache_key([1, '2', true], :name) end + + def test_expand_cache_key_with_rails_cache_id + begin + ENV['RAILS_CACHE_ID'] = 'c99' + assert_equal 'c99/foo', ActiveSupport::Cache.expand_cache_key(:foo) + assert_equal 'c99/foo', ActiveSupport::Cache.expand_cache_key([:foo]) + assert_equal 'c99/c99/foo/c99/bar', ActiveSupport::Cache.expand_cache_key([:foo, :bar]) + assert_equal 'nm/c99/foo', ActiveSupport::Cache.expand_cache_key(:foo, :nm) + assert_equal 'nm/c99/foo', ActiveSupport::Cache.expand_cache_key([:foo], :nm) + assert_equal 'nm/c99/c99/foo/c99/bar', ActiveSupport::Cache.expand_cache_key([:foo, :bar], :nm) + ensure + ENV['RAILS_CACHE_ID'] = nil + end + end + + def test_expand_cache_key_with_rails_app_version + begin + ENV['RAILS_APP_VERSION'] = 'rails3' + assert_equal 'rails3/foo', ActiveSupport::Cache.expand_cache_key(:foo) + ensure + ENV['RAILS_APP_VERSION'] = nil + end + end + + def test_expand_cache_key_rails_cache_id_should_win_over_rails_app_version + begin + ENV['RAILS_CACHE_ID'] = 'c99' + ENV['RAILS_APP_VERSION'] = 'rails3' + assert_equal 'c99/foo', ActiveSupport::Cache.expand_cache_key(:foo) + ensure + ENV['RAILS_CACHE_ID'] = nil + ENV['RAILS_APP_VERSION'] = nil + end + end + + def test_respond_to_cache_key + key = 'foo' + def key.cache_key + :foo_key + end + assert_equal 'foo_key', ActiveSupport::Cache.expand_cache_key(key) + end + end class CacheStoreSettingTest < ActiveSupport::TestCase |