feat: 🎸 add role set-grants ability

This commit is contained in:
Randall Morey committed 2021-09-30 15:21:45 -04:00
1 parent 1646132db3
commit 3022ca5a53
6 files changed
+112 -49

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
import ModelAbility from './model';
/**
* Provides abilities for roles.
*/
export default class RoleAbility extends ModelAbility {
// =permissions
/**
* @type {boolean}
*/
get canSetGrants() {
return this.hasAuthorizedAction('set-grants');
}
}
+1
View File
@@ -0,0 +1 @@
export { default } from 'api/abilities/role';
+1
View File
@@ -9,6 +9,7 @@ export default factory.extend({
'read',
'update',
'delete',
'set-grants',
],
// eslint-disable-next-line ember/avoid-leaking-state-in-ember-objects
grant_strings: () => [
@@ -0,0 +1,17 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Abilities | Account', function (hooks) {
setupTest(hooks);
test('it reflects when a given account may set grants based on authorized_actions', function (assert) {
assert.expect(2);
const service = this.owner.lookup('service:can');
const model = {
authorized_actions: ['set-grants'],
};
assert.ok(service.can('setGrants role', model));
model.authorized_actions = [];
assert.notOk(service.can('setGrants role', model));
});
});