mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix ActiveSupport::Cache::FileStore#file_path_key does not work if initialized with Pathname
Port from 3-1-stable
This commit is contained in:
parent
c3346b31c9
commit
49b0f9e395
2 changed files with 8 additions and 1 deletions
|
@ -16,7 +16,7 @@ module ActiveSupport
|
|||
|
||||
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 @@ class FileStoreTest < ActiveSupport::TestCase
|
|||
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 @@ class FileStoreTest < ActiveSupport::TestCase
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue