Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Merged
merged 1 commit into from

2 participants

@grzuy

Porting this pull request changes: #2213 from 3-1-stable to master branch

@spastorino spastorino merged commit e178fcb into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 23, 2011
  1. @grzuy

    Fix ActiveSupport::Cache::FileStore#file_path_key does not work if in…

    grzuy authored
    …itialized with Pathname
    
    Port from 3-1-stable
This page is out of date. Refresh to see the latest.
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
Something went wrong with that request. Please try again.