* chore: 🤖 reapply previous ember-can upgrade from #3093 * chore: 🤖 add missing ember-inflector dependency * chore: 🤖 move @ember/string to be a dependency in desktop * chore: 🤖 re-run pnpm install to resolve lockfile dupe key error * chore: 🤖 remove unused abilities service injections Co-Authored-By: Lisbet Alvarez <107949262+lisbet-alvarez@users.noreply.github.com> --------- Co-authored-by: Lisbet Alvarez <107949262+lisbet-alvarez@users.noreply.github.com>
41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
/**
|
|
* Copyright IBM Corp. 2021, 2026
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import { module, test } from 'qunit';
|
|
import { setupTest } from 'ember-qunit';
|
|
|
|
module('Unit | Abilities | Scope', function (hooks) {
|
|
setupTest(hooks);
|
|
|
|
let abilitiesService;
|
|
|
|
hooks.beforeEach(function () {
|
|
abilitiesService = this.owner.lookup('service:abilities');
|
|
});
|
|
test('it exists', function (assert) {
|
|
const ability = this.owner.lookup('ability:scope');
|
|
assert.ok(ability);
|
|
});
|
|
|
|
test('it reflects when a given scope may attach a policy in global scope', function (assert) {
|
|
const model = {
|
|
authorized_actions: ['attach-storage-policy'],
|
|
};
|
|
assert.true(abilitiesService.can('attachStoragePolicy scope', model));
|
|
model.authorized_actions = [];
|
|
assert.false(abilitiesService.can('attachStoragePolicy scope', model));
|
|
});
|
|
|
|
test('it reflects when a given scope may remove a policy in org scope', function (assert) {
|
|
const model = {
|
|
authorized_actions: ['detach-storage-policy'],
|
|
};
|
|
|
|
assert.true(abilitiesService.can('detachStoragePolicy scope', model));
|
|
model.authorized_actions = [];
|
|
assert.false(abilitiesService.can('detachStoragePolicy scope', model));
|
|
});
|
|
});
|