diff --git a/ui/app/serializers/node.js b/ui/app/serializers/node.js index 230057eb5..1084f442c 100644 --- a/ui/app/serializers/node.js +++ b/ui/app/serializers/node.js @@ -17,10 +17,8 @@ export default ApplicationSerializer.extend({ return assign({}, drivers[key], { Name: key }); }); - if (hash.HostVolumes) { - const hostVolumes = hash.HostVolumes; - hash.HostVolumes = Object.keys(hostVolumes).map(key => hostVolumes[key]); - } + const hostVolumes = hash.HostVolumes || {}; + hash.HostVolumes = Object.keys(hostVolumes).map(key => hostVolumes[key]); return this._super(modelClass, hash); }, diff --git a/ui/tests/unit/serializers/node-test.js b/ui/tests/unit/serializers/node-test.js index 2b807993d..2df5fb18b 100644 --- a/ui/tests/unit/serializers/node-test.js +++ b/ui/tests/unit/serializers/node-test.js @@ -163,6 +163,33 @@ module('Unit | Serializer | Node', function(hooks) { healthy: false, }, ], + hostVolumes: [], + }, + relationships: { + allocations: { + links: { + related: '/v1/node/test-node/allocations', + }, + }, + }, + }, + }, + }, + + { + name: 'Null hash values', + in: { + ID: 'test-node', + Drivers: null, + HostVolumes: null, + }, + out: { + data: { + id: 'test-node', + type: 'node', + attributes: { + hostVolumes: [], + drivers: [], }, relationships: { allocations: {