1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #41522 from ghiculescu/file-store-no-path

Require a path for `config.cache_store = :file_store`
This commit is contained in:
Ryuta Kamizono 2021-02-24 01:53:55 +09:00 committed by GitHub
commit 8cac41b841
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 2 deletions

View file

@ -63,7 +63,13 @@ module ActiveSupport
case store
when Symbol
options = parameters.extract_options!
retrieve_store_class(store).new(*parameters, **options)
# clean this up once Ruby 2.7 support is dropped
# see https://github.com/rails/rails/pull/41522#discussion_r581186602
if options.empty?
retrieve_store_class(store).new(*parameters)
else
retrieve_store_class(store).new(*parameters, **options)
end
when Array
lookup_store(*store)
when nil

View file

@ -20,7 +20,7 @@ module ActiveSupport
FILEPATH_MAX_SIZE = 900 # max is 1024, plus some room
GITKEEP_FILES = [".gitkeep", ".keep"].freeze
def initialize(cache_path, options = nil)
def initialize(cache_path, **options)
super(options)
@cache_path = cache_path.to_s
end

View file

@ -21,6 +21,12 @@ class CacheStoreSettingTest < ActiveSupport::TestCase
assert_equal "/path/to/cache/directory", store.cache_path
end
def test_file_store_requires_a_path
assert_raises(ArgumentError) do
ActiveSupport::Cache.lookup_store :file_store
end
end
def test_mem_cache_fragment_cache_store
assert_called_with(Dalli::Client, :new, [%w[localhost], {}]) do
store = ActiveSupport::Cache.lookup_store :mem_cache_store, "localhost"