Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore the lookup_store compatibility to accept config as a single object #38810

Merged
merged 1 commit into from Mar 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions activesupport/lib/active_support/cache.rb
Expand Up @@ -59,6 +59,8 @@ def lookup_store(store = nil, *parameters)
when Symbol
options = parameters.extract_options!
retrieve_store_class(store).new(*parameters, **options)
when Array
lookup_store(*store)
when nil
ActiveSupport::Cache::MemoryStore.new
else
Expand Down
8 changes: 8 additions & 0 deletions activesupport/test/cache/cache_store_setting_test.rb
Expand Up @@ -66,6 +66,14 @@ def test_object_assigned_fragment_cache_store
assert_equal "/path/to/cache/directory", store.cache_path
end

def test_redis_cache_store_with_single_array_object
cache_store = [:redis_cache_store, namespace: "foo"]

store = ActiveSupport::Cache.lookup_store(cache_store)
assert_kind_of ActiveSupport::Cache::RedisCacheStore, store
assert_equal "foo", store.options[:namespace]
end

def test_redis_cache_store_with_ordered_options
options = ActiveSupport::OrderedOptions.new
options.update namespace: "foo"
Expand Down