Fixed fragment_cached? method to check if caching

I noticed that fragment caching does not actually check if caching is
enabled as it seemingly should.

The way CachedSerializer#fragment_cached? worked previously would return
true even in an environment where caching was disabled as defined by
`ActiveModelSerializers.config.perform_caching`.

Added check for `_cache` like in the `cached?` method before checking
whether `_cache_only` or `_cache_except` is set.

There were no existing tests for any of these methods but it's a pretty
trivial change.
This commit is contained in:
Brian McManus 2016-01-28 13:47:17 -08:00
parent 65093055d6
commit 3a092c9b4b

View File

@ -24,7 +24,7 @@ module ActiveModel
end
def fragment_cached?
@klass._cache_only && !@klass._cache_except || !@klass._cache_only && @klass._cache_except
@klass._cache && (@klass._cache_only && !@klass._cache_except || !@klass._cache_only && @klass._cache_except)
end
def cache_key