Merge pull request #439 from nasa/open428

Fixed bug in copying #428
This commit is contained in:
Victor Woeltjen 2015-12-17 13:55:55 -08:00
commit 4848a61e21
2 changed files with 20 additions and 2 deletions

View File

@ -117,7 +117,7 @@ define(
if (Array.isArray(obj)) {
obj.forEach(function (value, index) {
obj[index] = idMap[value] || value;
this.rewriteIdentifiers(obj[index]);
this.rewriteIdentifiers(obj[index], idMap);
}, this);
} else if (obj && typeof obj === 'object') {
Object.keys(obj).forEach(function (key) {

View File

@ -105,7 +105,8 @@ define(
testModel = {
composition: [ ID_A, ID_B ],
someObj: {},
someArr: [ ID_A, ID_B ]
someArr: [ ID_A, ID_B ],
objArr: [{"id": ID_A}, {"id": ID_B}]
};
testModel.someObj[ID_A] = "some value";
testModel.someObj.someProperty = ID_B;
@ -242,6 +243,23 @@ define(
expect(domainObjectBClone.model.someObj.someProperty).toBe(childD_ID);
});
/**
* This a bug found in testathon when testing issue #428
*/
it(" and correctly updates child identifiers in object" +
" arrays within models ", function () {
var childA_ID = task.clones[0].getId(),
childB_ID = task.clones[1].getId(),
childC_ID = task.clones[3].getId(),
childD_ID = task.clones[4].getId();
expect(domainObjectClone.model.objArr[0].id).not.toBe(ID_A);
expect(domainObjectClone.model.objArr[0].id).toBe(childA_ID);
expect(domainObjectClone.model.objArr[1].id).not.toBe(ID_B);
expect(domainObjectClone.model.objArr[1].id).toBe(childB_ID);
});
});
});