We use adapter.findRecord to fetch repo by slug. Using it this way was
broken with one of the ember-data releases. This commit brings back the
old behaviour.
New ember-data serializers send data without a model key in the payload
by default, so instead of what API expects:
{
"hook": {
"id": 1,
"active": true
}
}
it would send:
{ "id": 1, "active": true }
Because of that we need to change how hooks are serialized.
Furthermore, API V2 returns just "result: true" after a successful
request to change a hook, so we need to return something meaningful from
the adapter's updateRecord in order to make ember-data happy.
One thing that is not standard here is a serializer for branch, which
uses @href as id. At this point branches don't have ids and ember-data
needs one, so using @href is the easiest way.
This commit adds adapters and serializers for v3, but also a fallback
serializer for v2, which allows to handle v2 and v3 payloads at the same
time. This is needed, because when we use v3 endpoint for one of the
models (in this case repo), we can also get embedded records of other
types (like branch or build).