Merge pull request #2111 from resin-io/store-efficient-plainify

minifix: remove stale json object plainifying in store
This commit is contained in:
Jonas Hermsmeier 2018-03-21 20:32:45 +01:00 committed by GitHub
commit c5b311359a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 27 deletions

View File

@ -168,8 +168,7 @@ const storeReducer = (state = DEFAULT_STATE, action) => {
})
}
// Convert object instances to plain objects
const drives = JSON.parse(JSON.stringify(action.data))
const drives = action.data
if (!_.isArray(drives) || !_.every(drives, _.isPlainObject)) {
throw errors.createError({

View File

@ -77,31 +77,6 @@ describe('Model: availableDrives', function () {
m.chai.expect(availableDrives.getDrives()).to.deep.equal(drives)
})
it('should be able to set non-plain drive objects', function () {
class Device {
constructor () {
this.device = '/dev/sdb'
this.description = 'Foo'
this.mountpoints = [ {
path: '/mnt/foo'
} ]
this.isSystem = false
}
}
availableDrives.setDrives([ new Device() ])
m.chai.expect(availableDrives.getDrives()).to.deep.equal([
{
device: '/dev/sdb',
description: 'Foo',
mountpoints: [ {
path: '/mnt/foo'
} ],
isSystem: false
}
])
})
it('should be able to set drives with extra properties', function () {
const drives = [
{