Preserve the serializer type when fragment caching

We were not previously cloning the type setting into the dynamically
generated cached/non-cached serializers for a given fragment-cached
serializer. This led to the type generated for JsonApi having the wrong
value when fragment caching is enabled by adding either :except or :only
options to cache.

This pulls the type setting from the fragment-cached serializer forward
onto the dynamic caching classes so it is preserved in the output.
This commit is contained in:
Brian McManus
2016-01-22 11:24:30 -08:00
committed by Benjamin Fleischer
parent 8981683b9f
commit d67f7da114
2 changed files with 17 additions and 1 deletions

View File

@@ -94,6 +94,10 @@ module ActiveModel
cached.constantize.cache(klass._cache_options)
# Preserve the type setting in the cached/non-cached serializer classes
cached.constantize.type(klass._type)
non_cached.constantize.type(klass._type)
cached.constantize.fragmented(serializer)
non_cached.constantize.fragmented(serializer)