Permalink
Browse files

Cache (FileStore) clear should keep .gitkeep

  • Loading branch information...
1 parent 1e69181 commit e5425c8f68fbb720fcbf4b14e1f154ac27dbbbed @tapajos tapajos committed Jan 13, 2012
Showing with 8 additions and 1 deletion.
  1. +1 −1 activesupport/lib/active_support/cache/file_store.rb
  2. +7 −0 activesupport/test/caching_test.rb
@@ -23,7 +23,7 @@ def initialize(cache_path, options = nil)
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
@@ -572,6 +572,13 @@ def cache_dir
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)

0 comments on commit e5425c8

Please sign in to comment.