rails-api/active_model_serializers — pull request #538 by mayhewluke (2014-04-02 05:01:34+00:00)
Title: Fix ArraySerializer's output when falling back on DefaultSerializer

As detailed in #495, `ArraySerializer`'s output sometimes contains unexpected root keys for each item of the array. This will happen when no serializer is defined for the array item and is caused by passing `:root => true` by default to `DefaultSerializer`. On the other hand, if any `ActiveModel::Serializer` is defined for the object the root keys will not be added.

This commit changes the instantiation of `DefaultSerializer` to pass `:root => false` instead. This ensures consistent results for serializing arrays regardless of whether or not a serializer has been defined for the array items. The tests added not only test that the root keys are not present but also test to make sure that this behaviour is consistent for both `DefaultSerializer` and custom serializers.