4 files changed
+8
-7
No files matched your search
@@ -28,7 +28,7 @@ export default class RoleSerializer extends ApplicationSerializer {
|
||||
serializeWithGrants(snapshot) {
|
||||
return {
|
||||
version: snapshot.attr('version'),
|
||||
grants: snapshot.attr('grants').map(grant => grant.attr('value'))
|
||||
grant_strings: snapshot.attr('grants').map(grant => grant.attr('value'))
|
||||
};
|
||||
}
|
||||
|
||||
@@ -42,8 +42,9 @@ export default class RoleSerializer extends ApplicationSerializer {
|
||||
*/
|
||||
normalize(modelClass, resourceHash) {
|
||||
// TODO: can fragment string normalization be handled generically?
|
||||
if (resourceHash.grants) {
|
||||
resourceHash.grants = resourceHash.grants.map(value => ({ value }));
|
||||
if (resourceHash.grant_strings) {
|
||||
resourceHash.grants =
|
||||
resourceHash.grant_strings.map(value => ({ value }));
|
||||
}
|
||||
return super.normalize(modelClass, resourceHash);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ module('Unit | Model | role', function (hooks) {
|
||||
this.server.post('/v1/scopes/o_1/roles/123abc:set-grants', (schema, request) => {
|
||||
const body = JSON.parse(request.requestBody);
|
||||
assert.deepEqual(body, {
|
||||
grants: ['grant1', 'grant2'],
|
||||
grant_strings: ['grant1', 'grant2'],
|
||||
version: 1
|
||||
});
|
||||
});
|
||||
|
||||
@@ -40,7 +40,7 @@ module('Unit | Serializer | role', function(hooks) {
|
||||
};
|
||||
const serializedRecord = serializer.serialize(snapshot);
|
||||
assert.deepEqual(serializedRecord, {
|
||||
grants: ['foo', 'bar'],
|
||||
grant_strings: ['foo', 'bar'],
|
||||
version: 1
|
||||
});
|
||||
});
|
||||
@@ -53,7 +53,7 @@ module('Unit | Serializer | role', function(hooks) {
|
||||
const payload = {
|
||||
id: '1',
|
||||
name: 'Role 1',
|
||||
grants: ['*', '*']
|
||||
grant_strings: ['*', '*']
|
||||
};
|
||||
const normalized = serializer.normalizeSingleResponse(
|
||||
store,
|
||||
|
||||
@@ -3,7 +3,7 @@ import factory from '../generated/factories/role';
|
||||
export default factory.extend({
|
||||
|
||||
// eslint-disable-next-line ember/avoid-leaking-state-in-ember-objects
|
||||
grants: [
|
||||
grant_strings: [
|
||||
'id=*;action=*',
|
||||
'id=*;type=host-catalog;actions=create,read'
|
||||
],
|
||||
|
||||
Reference in new issue
Block a user