2021-09-30 15:21:45 -04:00
|
|
|
import { module, test } from 'qunit';
|
|
|
|
|
import { setupTest } from 'ember-qunit';
|
|
|
|
|
|
2021-10-01 17:00:36 -04:00
|
|
|
module('Unit | Abilities | Role', function (hooks) {
|
2021-09-30 15:21:45 -04:00
|
|
|
setupTest(hooks);
|
|
|
|
|
|
2021-10-01 14:19:06 -04:00
|
|
|
test('it reflects when a given role may set grants based on authorized_actions', function (assert) {
|
2021-09-30 15:21:45 -04:00
|
|
|
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));
|
|
|
|
|
});
|
2021-09-30 16:04:02 -04:00
|
|
|
|
2021-10-01 14:19:06 -04:00
|
|
|
test('it reflects when a given role may add principals based on authorized_actions', function (assert) {
|
2021-09-30 16:04:02 -04:00
|
|
|
assert.expect(2);
|
|
|
|
|
const service = this.owner.lookup('service:can');
|
|
|
|
|
const model = {
|
|
|
|
|
authorized_actions: ['add-principals'],
|
|
|
|
|
};
|
|
|
|
|
assert.ok(service.can('addPrincipals role', model));
|
|
|
|
|
model.authorized_actions = [];
|
|
|
|
|
assert.notOk(service.can('addPrincipals role', model));
|
|
|
|
|
});
|
|
|
|
|
|
2021-10-01 14:19:06 -04:00
|
|
|
test('it reflects when a given role may remove principals based on authorized_actions', function (assert) {
|
2021-09-30 16:04:02 -04:00
|
|
|
assert.expect(2);
|
|
|
|
|
const service = this.owner.lookup('service:can');
|
|
|
|
|
const model = {
|
|
|
|
|
authorized_actions: ['remove-principals'],
|
|
|
|
|
};
|
|
|
|
|
assert.ok(service.can('removePrincipals role', model));
|
|
|
|
|
model.authorized_actions = [];
|
|
|
|
|
assert.notOk(service.can('removePrincipals role', model));
|
|
|
|
|
});
|
2021-09-30 15:21:45 -04:00
|
|
|
});
|