diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2011-07-23 14:05:15 -0700 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2011-07-23 14:05:15 -0700 |
commit | e178fcbd01e3a37ff906a5189f0b2bcff5a973b9 (patch) | |
tree | 63fb1611847e78886a05dbad3a8e2ae10afad26e | |
parent | c3346b31c9ddb564bdd0648e03f077035fcaacb9 (diff) | |
parent | 49b0f9e3950a529dbab6e930a0bb44035d96484f (diff) | |
download | rails-e178fcbd01e3a37ff906a5189f0b2bcff5a973b9.tar.gz rails-e178fcbd01e3a37ff906a5189f0b2bcff5a973b9.tar.bz2 rails-e178fcbd01e3a37ff906a5189f0b2bcff5a973b9.zip |
Merge pull request #2221 from grzuy/master
Fix ActiveSupport::Cache::FileStore#file_path_key does not work if initialized with Pathname
-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 c4da04e532..f7c01948b4 100644 --- a/activesupport/lib/active_support/cache/file_store.rb +++ b/activesupport/lib/active_support/cache/file_store.rb @@ -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 diff --git a/activesupport/test/caching_test.rb b/activesupport/test/caching_test.rb index 8b3e4800c3..402c6695aa 100644 --- a/activesupport/test/caching_test.rb +++ b/activesupport/test/caching_test.rb @@ -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 |