Skip to content

Commit

Permalink
Merge pull request #38810 from kamipo/restore_compatibility_for_looku…
Browse files Browse the repository at this point in the history
…p_store

Restore the `lookup_store` compatibility to accept config as a single object
  • Loading branch information
kamipo committed Mar 25, 2020
1 parent 7d11f6e commit 5665d08
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions activesupport/lib/active_support/cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,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
Original file line number Diff line number Diff line change
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

0 comments on commit 5665d08

Please sign in to comment.