fix: 🐛 is_primary should default to false
This commit is contained in:
2 files changed
+19
-2
No files matched your search
@@ -15,4 +15,21 @@ export default class AuthMethodSerializer extends ApplicationSerializer {
|
||||
);
|
||||
return normalized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets `is_primary` to `false` if it is missing in the response. The API
|
||||
* omits "zero" values per:
|
||||
* https://developers.google.com/protocol-buffers/docs/proto3#default
|
||||
*
|
||||
* TODO: generalize this so that all zero values are reified.
|
||||
* @override
|
||||
* @return {object}
|
||||
*/
|
||||
normalize() {
|
||||
const normalized = super.normalize(...arguments);
|
||||
if (!normalized.data.attributes.is_primary) {
|
||||
normalized.data.attributes.is_primary = false;
|
||||
}
|
||||
return normalized;
|
||||
}
|
||||
}
|
||||
@@ -49,13 +49,13 @@ module('Unit | Serializer | auth method', function (hooks) {
|
||||
{
|
||||
id: '1',
|
||||
type: 'auth-method',
|
||||
attributes: {},
|
||||
attributes: { is_primary: false },
|
||||
relationships: {},
|
||||
},
|
||||
{
|
||||
id: '3',
|
||||
type: 'auth-method',
|
||||
attributes: {},
|
||||
attributes: { is_primary: false },
|
||||
relationships: {},
|
||||
},
|
||||
],
|
||||
|
||||
Reference in new issue
Block a user