feat: Add account attributes to account model
This commit is contained in:
6 files changed
+59
-1
No files matched your search
@@ -1,3 +1,12 @@
|
||||
import GeneratedAccountModel from '../generated/models/account';
|
||||
import { fragment } from 'ember-data-model-fragments/attributes';
|
||||
|
||||
export default class AccountModel extends GeneratedAccountModel {}
|
||||
export default class AccountModel extends GeneratedAccountModel {
|
||||
|
||||
/**
|
||||
* Attributes of this resource, if any, represented as a JSON fragment.
|
||||
* @type {FragmentAccountAttributesModel}
|
||||
*/
|
||||
@fragment('fragment-account-attributes', { defaultValue: {} }) attributes;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import Fragment from 'ember-data-model-fragments/fragment';
|
||||
import { attr } from '@ember-data/model';
|
||||
|
||||
export default class FragmentAccountAttributesModel extends Fragment {
|
||||
|
||||
@attr('string', {
|
||||
description: 'The account login name'
|
||||
}) login_name;
|
||||
|
||||
@attr('string', {
|
||||
description: 'The account password'
|
||||
}) password;
|
||||
}
|
||||
@@ -6,4 +6,5 @@ export default class FragmentHostAttributesModel extends Fragment {
|
||||
@attr('string', {
|
||||
description: 'The address (DNS or IP name) used to reach the host'
|
||||
}) address;
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from 'api/models/fragment-account-attributes';
|
||||
@@ -10,4 +10,15 @@ module('Unit | Model | account', function(hooks) {
|
||||
let model = store.createRecord('account', {});
|
||||
assert.ok(model);
|
||||
});
|
||||
|
||||
test('it contains attributes', function(assert) {
|
||||
let store = this.owner.lookup('service:store');
|
||||
let model = store.createRecord('account', {
|
||||
type: 'password',
|
||||
attributes: {
|
||||
login_name: 'loginname'
|
||||
}
|
||||
});
|
||||
assert.equal(model.attributes.login_name, 'loginname');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user