chore: 🤖 Add group model to api addon
This commit is contained in:
5 files changed
+86
-1
No files matched your search
@@ -0,0 +1,36 @@
|
||||
import BaseModel from '../../models/base';
|
||||
import { attr } from '@ember-data/model';
|
||||
|
||||
/**
|
||||
* Group contains all fields related to a Group resource
|
||||
*/
|
||||
export default class GeneratedGroupModel extends BaseModel {
|
||||
// = attributes
|
||||
|
||||
@attr('string', {
|
||||
description: 'Optional name for identification purposes',
|
||||
})
|
||||
name;
|
||||
|
||||
@attr('string', {
|
||||
description: 'Optional user-set description for identification purposes',
|
||||
})
|
||||
description;
|
||||
|
||||
@attr('date', {
|
||||
description: 'The time this resource was created\nOutput only.',
|
||||
readOnly: true,
|
||||
})
|
||||
created_time;
|
||||
|
||||
@attr('date', {
|
||||
description: 'The time this resource was last updated\nOutput only.',
|
||||
readOnly: true,
|
||||
})
|
||||
updated_time;
|
||||
|
||||
@attr('boolean', {
|
||||
description: 'Whether the resource is disabled',
|
||||
})
|
||||
disabled;
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import BaseModel from '../../models/base';
|
||||
import { attr } from '@ember-data/model';
|
||||
|
||||
/**
|
||||
* Contains a Role resource
|
||||
* Role contains all fields related to a Role resource
|
||||
*/
|
||||
export default class GeneratedRoleModel extends BaseModel {
|
||||
// = attributes
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import GeneratedGroupModel from '../generated/models/group';
|
||||
|
||||
export default class GroupModel extends GeneratedGroupModel {}
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from 'api/models/group';
|
||||
@@ -0,0 +1,45 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Model | group', function(hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
let model;
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
let store = this.owner.lookup('service:store');
|
||||
model = store.createRecord('group', {});
|
||||
});
|
||||
|
||||
test('it exists', function (assert) {
|
||||
assert.ok(model);
|
||||
});
|
||||
|
||||
test('it supports name attr', function (assert) {
|
||||
model.set('name', 'Group name');
|
||||
assert.equal(model.name, 'Group name');
|
||||
});
|
||||
|
||||
test('it supports description attr', function (assert) {
|
||||
model.set('description', 'Group description');
|
||||
assert.equal(model.description, 'Group description');
|
||||
});
|
||||
|
||||
test('it supports created time attr', function (assert) {
|
||||
const createdTime = new Date();
|
||||
model.set('created_time', createdTime);
|
||||
assert.equal(model.created_time, createdTime);
|
||||
});
|
||||
|
||||
test('it supports updated time attr', function (assert) {
|
||||
const updatedTime = new Date();
|
||||
model.set('updated_time', updatedTime);
|
||||
assert.equal(model.updated_time, updatedTime);
|
||||
});
|
||||
|
||||
test('it supports disabled attr', function (assert) {
|
||||
assert.notOk(model.disabled);
|
||||
model.set('disabled', true);
|
||||
assert.ok(model.disabled);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user