Adds better support for relationships with regards to
ActiveModel::Serializers through Canvas::APISerializer:
- Serializing a url is now the default if your relationship is
`embed: :ids` (implied embed_in_root: false)
- Serializing IDs is the default if your relationship is
`embed: :ids, embed_in_root: true` (relationship is sideloaded with
the main response)
- Stringifying ids is now the default. You can opt out by defining
a `stringify_ids?` method on your serializer.
- Introduce Canvas::APIArraySerializer for our own needs since
ActiveModel::ArraySerializer calls `serializable_object` instead
of `as_json`, bypassing stringification.
Also fixes an issue where subclassing Canvas::APISerializer
would not get stringified if you overrode `serializable_object`.
test plan:
- make sure the jsonapi version of the quizzes api still works.
Change-Id: I301648d3e21b887eb7c2502cc00dec023fbbf79d
Reviewed-on: https://gerrit.instructure.com/28116
QA-Review: Myller de Araujo <myller@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Product-Review: Stanley Stuart <stanley@instructure.com>
test plan:
- The quiz api should work like it normally does when you don't pass
an 'Accept: application/vnd.api+json' header.
- The quizzes index page and quiz edit page should work like they
always do.
- Testing the Quizzes API for "jsonapi" style:
- For all requests, you MUST have the "Accept" header set to
"application/vnd.api+json"
- Test all the endpoints (PUT, POST, GET, INDEX, DELETE) like you
normally would, except you'll need to format the data according to
the next few steps:
- For "POST" and "PUT" (create and update) requests, you should send
the data like: { "quizzes": [ { id: 1, title: "blah" } ]
- For all requests (except DELETE), you should get back a response
that looks like: { "quizzes": [ { quiz you requested } ]
- For the "delete" action, you should get a "no content" response
and the request should be successful
Change-Id: Ie91deaeb6772cbe52a0fc46a28ab93a4e3036061
Reviewed-on: https://gerrit.instructure.com/25997
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Stanley Stuart <stanley@instructure.com>