diff options
author | Rei <chloerei@gmail.com> | 2018-04-15 00:43:14 +0800 |
---|---|---|
committer | Rei <chloerei@gmail.com> | 2018-04-15 00:43:14 +0800 |
commit | 92db9e46f8dced015a236f073187e4ea50c7e13c (patch) | |
tree | fd5970063a29a0d2386d6b478b9e6b8832e2eaf4 /activesupport/test | |
parent | 662ba236d115d3e2152b04dcdefdc0ee6f1f6102 (diff) | |
download | rails-92db9e46f8dced015a236f073187e4ea50c7e13c.tar.gz rails-92db9e46f8dced015a236f073187e4ea50c7e13c.tar.bz2 rails-92db9e46f8dced015a236f073187e4ea50c7e13c.zip |
Fix redis store clear keys outside the namespace
Namespace not working in RedisCacheStore#clear method. Bacause
namespace = merged_options(options)[namespace]
is always nil, Correct is
namespace = merged_options(options)[:namespace]
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/cache/stores/redis_cache_store_test.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/activesupport/test/cache/stores/redis_cache_store_test.rb b/activesupport/test/cache/stores/redis_cache_store_test.rb index dda96b68fb..3cae2bb11f 100644 --- a/activesupport/test/cache/stores/redis_cache_store_test.rb +++ b/activesupport/test/cache/stores/redis_cache_store_test.rb @@ -221,4 +221,22 @@ module ActiveSupport::Cache::RedisCacheStoreTests end end end + + class ClearTest < StoreTest + test "clear all cache key" do + @cache.write("foo", "bar") + @cache.write("fu", "baz") + @cache.clear + assert !@cache.exist?("foo") + assert !@cache.exist?("fu") + end + + test "only clear namespace cache key" do + @cache.write("foo", "bar") + @cache.redis.set("fu", "baz") + @cache.clear + assert !@cache.exist?("foo") + assert @cache.redis.exists("fu") + end + end end |