Move caching initialization to Railtie

Also
- Add reference to config from ActiveModelSerializers.config
- correctly call super in FragmentCacheTest#setup
- rename test rails app from Foo to ActiveModelSerializers::RailsApplication
This commit is contained in:
Benjamin Fleischer
2015-11-10 01:39:30 -06:00
parent 2bea7f94f3
commit a9ce4fb766
5 changed files with 20 additions and 4 deletions

View File

@@ -152,7 +152,7 @@ module ActiveModel
# @todo require less code comments. See
# https://github.com/rails-api/active_model_serializers/pull/1249#issuecomment-146567837
def self.cache(options = {})
self._cache = ActionController::Base.cache_store if Rails.configuration.action_controller.perform_caching
self._cache = ActiveModelSerializers.config.cache_store if ActiveModelSerializers.config.perform_caching
self._cache_key = options.delete(:key)
self._cache_only = options.delete(:only)
self._cache_except = options.delete(:except)