diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb index d3b7f7395d..fc17d17bef 100644 --- a/activesupport/lib/active_support/cache.rb +++ b/activesupport/lib/active_support/cache.rb @@ -53,8 +53,7 @@ module ActiveSupport # # ActiveSupport::Cache.lookup_store(MyOwnCacheStore.new) # # => returns MyOwnCacheStore.new - def lookup_store(*store_option) - store, *parameters = *Array.wrap(store_option).flatten + def lookup_store(store = nil, *parameters) case store when Symbol diff --git a/railties/lib/rails/application/bootstrap.rb b/railties/lib/rails/application/bootstrap.rb index 1fdc7b2d71..295c073791 100644 --- a/railties/lib/rails/application/bootstrap.rb +++ b/railties/lib/rails/application/bootstrap.rb @@ -56,7 +56,7 @@ module Rails # Initialize cache early in the stack so railties can make use of it. initializer :initialize_cache, group: :all do unless Rails.cache - Rails.cache = ActiveSupport::Cache.lookup_store(config.cache_store) + Rails.cache = ActiveSupport::Cache.lookup_store(*config.cache_store) if Rails.cache.respond_to?(:middleware) config.middleware.insert_before(::Rack::Runtime, Rails.cache.middleware) diff --git a/railties/test/application/middleware_test.rb b/railties/test/application/middleware_test.rb index e93f2f5aa4..dcec088991 100644 --- a/railties/test/application/middleware_test.rb +++ b/railties/test/application/middleware_test.rb @@ -239,9 +239,10 @@ module ApplicationTests end test "Rails.cache does not respond to middleware" do - add_to_config "config.cache_store = :memory_store" + add_to_config "config.cache_store = :memory_store, { timeout: 10 }" boot! assert_equal "Rack::Runtime", middleware[5] + assert_instance_of ActiveSupport::Cache::MemoryStore, Rails.cache end test "Rails.cache does respond to middleware" do