aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorNeeraj Singh <neerajdotname@gmail.com>2010-07-27 21:57:15 +0800
committerJosé Valim <jose.valim@gmail.com>2010-07-28 21:02:45 +0800
commit4952a80200cf916636b1e0ca11985bbd09f42a80 (patch)
treecd221100013f75b2428bc081eabad668db30342e /activesupport/test
parent7d29627be91027cb6b616d21bc97e5066901d907 (diff)
downloadrails-4952a80200cf916636b1e0ca11985bbd09f42a80.tar.gz
rails-4952a80200cf916636b1e0ca11985bbd09f42a80.tar.bz2
rails-4952a80200cf916636b1e0ca11985bbd09f42a80.zip
adding test for respond_to cache_key and cleaning up the ENV settings
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/caching_test.rb47
1 files changed, 33 insertions, 14 deletions
diff --git a/activesupport/test/caching_test.rb b/activesupport/test/caching_test.rb
index 8497e44554..b79a7bbaec 100644
--- a/activesupport/test/caching_test.rb
+++ b/activesupport/test/caching_test.rb
@@ -9,26 +9,45 @@ class CacheKeyTest < ActiveSupport::TestCase
end
def test_expand_cache_key_with_rails_cache_id
- ENV['RAILS_APP_VERSION'] = nil
- 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)
+ 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
- ENV['RAILS_CACHE_ID'] = nil
- ENV['RAILS_APP_VERSION'] = 'rails3'
- assert_equal 'rails3/foo', ActiveSupport::Cache.expand_cache_key(:foo)
+ 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
- ENV['RAILS_CACHE_ID'] = 'c99'
- ENV['RAILS_APP_VERSION'] = 'rails3'
- assert_equal 'c99/foo', ActiveSupport::Cache.expand_cache_key(:foo)
+ 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