class CacheKeyTest
Public Class Methods
new(value, options = {})
click to toggle source
Calls superclass method
# File activesupport/test/cache/cache_key_test.rb, line 9 def initialize(value, options = {}) @value = value @expires_in = nil @created_at = nil super end
Public Instance Methods
test_entry_legacy_optional_ivars()
click to toggle source
# File activesupport/test/cache/cache_key_test.rb, line 7 def test_entry_legacy_optional_ivars legacy = Class.new(ActiveSupport::Cache::Entry) do def initialize(value, options = {}) @value = value @expires_in = nil @created_at = nil super end end entry = legacy.new "foo" assert_equal "foo", entry.value end
test_expand_cache_key()
click to toggle source
# File activesupport/test/cache/cache_key_test.rb, line 21 def test_expand_cache_key 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
test_expand_cache_key_array_with_something_that_responds_to_cache_key()
click to toggle source
# File activesupport/test/cache/cache_key_test.rb, line 57 def test_expand_cache_key_array_with_something_that_responds_to_cache_key key = "foo".dup def key.cache_key :foo_key end assert_equal "foo_key", ActiveSupport::Cache.expand_cache_key([key]) end
test_expand_cache_key_of_array_like_object()
click to toggle source
# File activesupport/test/cache/cache_key_test.rb, line 77 def test_expand_cache_key_of_array_like_object assert_equal "foo/bar/baz", ActiveSupport::Cache.expand_cache_key(%w{foo bar baz}.to_enum) end
test_expand_cache_key_of_false()
click to toggle source
# File activesupport/test/cache/cache_key_test.rb, line 69 def test_expand_cache_key_of_false assert_equal "false", ActiveSupport::Cache.expand_cache_key(false) end
test_expand_cache_key_of_nil()
click to toggle source
# File activesupport/test/cache/cache_key_test.rb, line 65 def test_expand_cache_key_of_nil assert_equal "", ActiveSupport::Cache.expand_cache_key(nil) end
test_expand_cache_key_of_true()
click to toggle source
# File activesupport/test/cache/cache_key_test.rb, line 73 def test_expand_cache_key_of_true assert_equal "true", ActiveSupport::Cache.expand_cache_key(true) end
test_expand_cache_key_quails_cache_id_should_win_over_quails_app_version()
click to toggle source
# File activesupport/test/cache/cache_key_test.rb, line 43 def test_expand_cache_key_quails_cache_id_should_win_over_quails_app_version with_env("RAILS_CACHE_ID" => "c99", "RAILS_APP_VERSION" => "quails3") do assert_equal "c99/foo", ActiveSupport::Cache.expand_cache_key(:foo) end end
test_expand_cache_key_respond_to_cache_key()
click to toggle source
# File activesupport/test/cache/cache_key_test.rb, line 49 def test_expand_cache_key_respond_to_cache_key key = "foo".dup def key.cache_key :foo_key end assert_equal "foo_key", ActiveSupport::Cache.expand_cache_key(key) end
test_expand_cache_key_with_quails_app_version()
click to toggle source
# File activesupport/test/cache/cache_key_test.rb, line 37 def test_expand_cache_key_with_quails_app_version with_env("RAILS_APP_VERSION" => "quails3") do assert_equal "quails3/foo", ActiveSupport::Cache.expand_cache_key(:foo) end end
test_expand_cache_key_with_quails_cache_id()
click to toggle source
# File activesupport/test/cache/cache_key_test.rb, line 26 def test_expand_cache_key_with_quails_cache_id with_env("RAILS_CACHE_ID" => "c99") do assert_equal "c99/foo", ActiveSupport::Cache.expand_cache_key(:foo) assert_equal "c99/foo", ActiveSupport::Cache.expand_cache_key([:foo]) assert_equal "c99/foo/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/foo/bar", ActiveSupport::Cache.expand_cache_key([:foo, :bar], :nm) end end
Private Instance Methods
with_env(kv) { || ... }
click to toggle source
# File activesupport/test/cache/cache_key_test.rb, line 83 def with_env(kv) old_values = {} kv.each { |key, value| old_values[key], ENV[key] = ENV[key], value } yield ensure old_values.each { |key, value| ENV[key] = value } end