Skip to content

Commit

Permalink
feat(orga): add isScoAndManagingStudents and isGarIdentityProvider ge…
Browse files Browse the repository at this point in the history
…tter

in organization model
  • Loading branch information
er-lim committed Sep 11, 2024
1 parent 0262812 commit 83f9b05
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
8 changes: 8 additions & 0 deletions orga/app/models/organization.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export default class Organization extends Model {
@hasMany('group', { async: true, inverse: null }) groups;
@hasMany('division', { async: true, inverse: null }) divisions;

get isGarIdentityProvider() {
return this.isScoAndManagingStudents && this.identityProviderForCampaigns === 'GAR';
}

get isPro() {
return this.type === 'PRO';
}
Expand All @@ -26,6 +30,10 @@ export default class Organization extends Model {
return this.type === 'SCO';
}

get isScoAndManagingStudents() {
return this.isSco && this.isManagingStudents;
}

get isSco1d() {
return this.type === 'SCO-1D';
}
Expand Down
67 changes: 67 additions & 0 deletions orga/tests/unit/models/organization-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { setupTest } from 'ember-qunit';
import { module, test } from 'qunit';

module('Unit | Model | organization', function (hooks) {
setupTest(hooks);

module('#isScoAndManagingStudents', function () {
test("it returns true when organization has 'SCO' type and isManagingStudents at true", function (assert) {
// given
const store = this.owner.lookup('service:store');

// when
const organization = store.createRecord('organization', {
isManagingStudents: true,
type: 'SCO',
});

// then
assert.true(organization.isScoAndManagingStudents);
});

test("it returns false when organization does not have 'SCO' type or isManagingStudents at true", function (assert) {
// given
const store = this.owner.lookup('service:store');

// when
const organization = store.createRecord('organization', {
isManagingStudents: false,
type: 'PRO',
});

// then
assert.false(organization.isScoAndManagingStudents);
});
});
module('#isGarIdentityProvider', function () {
test("it returns true when organization isScoAndManagingStudents and identityProviderForCampaigns 'GAR'", function (assert) {
// given
const store = this.owner.lookup('service:store');

// when
const organization = store.createRecord('organization', {
isManagingStudents: true,
type: 'SCO',
identityProviderForCampaigns: 'GAR',
});

// then
assert.true(organization.isGarIdentityProvider);
});

test("it returns false when organization does not have isScoAndManagingStudents or identityProviderForCampaigns 'GAR'", function (assert) {
// given
const store = this.owner.lookup('service:store');

// when
const organization = store.createRecord('organization', {
isManagingStudents: true,
type: 'SCO',
identityProviderForCampaigns: 'TEST',
});

// then
assert.false(organization.isGarIdentityProvider);
});
});
});

0 comments on commit 83f9b05

Please sign in to comment.