diff options
author | Marcos Tapajos <tapajos@gmail.com> | 2012-01-13 00:14:11 -0200 |
---|---|---|
committer | Marcos Tapajos <tapajos@gmail.com> | 2012-01-13 13:28:16 -0200 |
commit | e5425c8f68fbb720fcbf4b14e1f154ac27dbbbed (patch) | |
tree | 8df2ae95ae099b6a3daefaa758222517bc489ea8 /activesupport | |
parent | 1e69181c5f4120d604fe86a9c2620694760d6c8e (diff) | |
download | rails-e5425c8f68fbb720fcbf4b14e1f154ac27dbbbed.tar.gz rails-e5425c8f68fbb720fcbf4b14e1f154ac27dbbbed.tar.bz2 rails-e5425c8f68fbb720fcbf4b14e1f154ac27dbbbed.zip |
Cache (FileStore) clear should keep .gitkeep
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/cache/file_store.rb | 2 | ||||
-rw-r--r-- | activesupport/test/caching_test.rb | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/cache/file_store.rb b/activesupport/lib/active_support/cache/file_store.rb index 9460532af0..1604cd12af 100644 --- a/activesupport/lib/active_support/cache/file_store.rb +++ b/activesupport/lib/active_support/cache/file_store.rb @@ -23,7 +23,7 @@ module ActiveSupport end def clear(options = nil) - root_dirs = Dir.entries(cache_path).reject{|f| f.in?(EXCLUDED_DIRS)} + root_dirs = Dir.entries(cache_path).reject{|f| f.in?(EXCLUDED_DIRS + [".gitkeep"])} FileUtils.rm_r(root_dirs.collect{|f| File.join(cache_path, f)}) end diff --git a/activesupport/test/caching_test.rb b/activesupport/test/caching_test.rb index 3454c378d3..030e31d158 100644 --- a/activesupport/test/caching_test.rb +++ b/activesupport/test/caching_test.rb @@ -572,6 +572,13 @@ class FileStoreTest < ActiveSupport::TestCase include CacheDeleteMatchedBehavior include CacheIncrementDecrementBehavior + def test_clear + filepath = File.join(cache_dir, ".gitkeep") + FileUtils.touch(filepath) + @cache.clear + assert File.exist?(filepath) + end + def test_key_transformation key = @cache.send(:key_file_path, "views/index?id=1") assert_equal "views/index?id=1", @cache.send(:file_path_key, key) |