Skip to content
Browse files

Merge pull request #2221 from grzuy/master

Fix ActiveSupport::Cache::FileStore#file_path_key does not work if initialized with Pathname
  • Loading branch information...
2 parents c3346b3 + 49b0f9e commit e178fcbd01e3a37ff906a5189f0b2bcff5a973b9 @spastorino spastorino committed Jul 23, 2011
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
View
2 activesupport/lib/active_support/cache/file_store.rb
@@ -16,7 +16,7 @@ class FileStore < Store
def initialize(cache_path, options = nil)
super(options)
- @cache_path = cache_path
+ @cache_path = cache_path.to_s
extend Strategy::LocalCache
end
View
7 activesupport/test/caching_test.rb
@@ -521,6 +521,7 @@ def setup
Dir.mkdir(cache_dir) unless File.exist?(cache_dir)
@cache = ActiveSupport::Cache.lookup_store(:file_store, cache_dir, :expires_in => 60)
@peek = ActiveSupport::Cache.lookup_store(:file_store, cache_dir, :expires_in => 60)
+ @cache_with_pathname = ActiveSupport::Cache.lookup_store(:file_store, Pathname.new(cache_dir), :expires_in => 60)
end
def teardown
@@ -540,6 +541,12 @@ 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)
end
+
+ def test_key_transformation_with_pathname
+ FileUtils.touch(File.join(cache_dir, "foo"))
+ key = @cache_with_pathname.send(:key_file_path, "views/index?id=1")
+ assert_equal "views/index?id=1", @cache_with_pathname.send(:file_path_key, key)
+ end
end
class MemoryStoreTest < ActiveSupport::TestCase

0 comments on commit e178fcb

Please sign in to comment.
Something went wrong with that request. Please try again.