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