The ActiveModel::Serializer.type method now accepts symbol as paremeter:
class AuthorSerializer < ActiveModel::Serializer
type :profile
end
The test file for the type was also refactored.
Fix the "Calling deprecated ArraySerializer... Please use
CollectionSerializer" warning that appeared when running the specs. This
happened because on of the test called ArraySerializer instead of
CollectionSerializer.
When using the relationship link with a block, calling "meta" without "href", e.g.
has_one :bio do
link :related do
meta id: 1
end
end
results in in a nil "href", e.g.
{ links: { posts: { related: { href: nil, meta: { id: 1 } } } } }.
According to JSONAPI, we should be able to use meta without href
(http://jsonapi.org/format/#document-links).
When using the relationships DSL with a block e.g.
has_one :bio do
link :self, "some_link"
end
the "data" field would be rendered with a nil value even though the bio
is not nil. This happened because the block return value was set to nil
but used as a value for the "data" field.
PR #1454 was merged with some missing fixes. All these fixes are
addressed by this commit:
- Rename ActiveModel::Serializer::Adapter::JsonApi::Association to
ActiveModel::Serializer::Adapter::JsonApi::Relationship
- Move ActiveModel::Serializer::Adapter:: JsonApi::Relationship and
ActiveModel::Serializer::Adapter::JsonApi::ResourceIdentifier to
ActiveModel::Serializer::Adapter::JsonApi::ApiObjects module
- Add unit test for
ActiveModel::Serializer::Adapter::JsonApi::Relationship
- Add unit test for
ActiveModel::Serializer::Adapter::JsonApi::ResourceIdentifier
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.
http://jsonapi.org/format/#document-top-level
fix failing tests
support for top-level links limited to jsonapi adapter
Move docs from README to docs/ dir
move links to json-api adapter & create Links class to hold links data
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.