From 4c0cb1c2c9269c74588da9f114f52ea3707ae8fb Mon Sep 17 00:00:00 2001 From: George Claghorn Date: Tue, 16 Jan 2018 09:20:47 -0500 Subject: Fix constant reference Update the long key handling test so it triggers truncation in the Redis cache store. --- activesupport/lib/active_support/cache/redis_cache_store.rb | 2 +- activesupport/test/cache/behaviors/cache_store_behavior.rb | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/activesupport/lib/active_support/cache/redis_cache_store.rb b/activesupport/lib/active_support/cache/redis_cache_store.rb index 6cc45f5284..e7f015bff5 100644 --- a/activesupport/lib/active_support/cache/redis_cache_store.rb +++ b/activesupport/lib/active_support/cache/redis_cache_store.rb @@ -368,7 +368,7 @@ module ActiveSupport def truncate_key(key) if key.bytesize > max_key_bytesize - suffix = ":sha2:#{Digest::SHA2.hexdigest(key)}" + suffix = ":sha2:#{::Digest::SHA2.hexdigest(key)}" truncate_at = max_key_bytesize - suffix.bytesize "#{key.byteslice(0, truncate_at)}#{suffix}" else diff --git a/activesupport/test/cache/behaviors/cache_store_behavior.rb b/activesupport/test/cache/behaviors/cache_store_behavior.rb index bdc689b8b4..ac37ab6e61 100644 --- a/activesupport/test/cache/behaviors/cache_store_behavior.rb +++ b/activesupport/test/cache/behaviors/cache_store_behavior.rb @@ -309,8 +309,7 @@ module CacheStoreBehavior end def test_really_long_keys - key = "".dup - 900.times { key << "x" } + key = "x" * 2048 assert @cache.write(key, "bar") assert_equal "bar", @cache.read(key) assert_equal "bar", @cache.fetch(key) -- cgit v1.2.3