feat: 🎸 Refactor modeling
Remove OIDC as default value for fragment field filter. Applied default value OIDC to type field. Accomodate tests for the changes. Add a readOnly serializer test. Delete from fragment serializer not serializing readOnly, because that is a case it will never reproduce on such model.
This commit is contained in:
1 parent
2620607cc3
commit
5df6b6de11
4 files changed
+66
-10
No files matched your search
@@ -36,6 +36,7 @@ export default class GeneratedManagedGroupModel extends BaseModel {
|
||||
|
||||
@attr('string', {
|
||||
description: 'The type of this ManagedGroup.',
|
||||
defaultValue: () => 'OIDC',
|
||||
})
|
||||
type;
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ export default class FragmentManagedGroupsAttributesModel extends Fragment {
|
||||
@attr('string', {
|
||||
description:
|
||||
'The boolean expression filter to use to determine membership.',
|
||||
defaultValue: () => 'OIDC',
|
||||
})
|
||||
filter;
|
||||
}
|
||||
@@ -12,12 +12,10 @@ export default class FragmentManagedGroupsAttributesSerializer extends JSONSeria
|
||||
* @param {Object} attribute
|
||||
*/
|
||||
serializeAttribute(snapshot, json, key, attribute) {
|
||||
const { type, options } = attribute;
|
||||
const { type } = attribute;
|
||||
let value = super.serializeAttribute(...arguments);
|
||||
// Convert empty string to null.
|
||||
if (type === 'string' && json[key] === '') json[key] = null;
|
||||
// Do not serialize read-only attributes.
|
||||
if (options.readOnly) delete json[key];
|
||||
return value;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user