提交 49b0f9e3 编写于 作者: G Gonzalo Rodriguez

Fix ActiveSupport::Cache::FileStore#file_path_key does not work if initialized with Pathname

Port from 3-1-stable
上级 c3346b31
......@@ -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
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册