Fixed bug in copying #428
This commit is contained in:
@@ -117,7 +117,7 @@ define(
|
|||||||
if (Array.isArray(obj)) {
|
if (Array.isArray(obj)) {
|
||||||
obj.forEach(function (value, index) {
|
obj.forEach(function (value, index) {
|
||||||
obj[index] = idMap[value] || value;
|
obj[index] = idMap[value] || value;
|
||||||
this.rewriteIdentifiers(obj[index]);
|
this.rewriteIdentifiers(obj[index], idMap);
|
||||||
}, this);
|
}, this);
|
||||||
} else if (obj && typeof obj === 'object') {
|
} else if (obj && typeof obj === 'object') {
|
||||||
Object.keys(obj).forEach(function (key) {
|
Object.keys(obj).forEach(function (key) {
|
||||||
|
|||||||
@@ -105,7 +105,8 @@ define(
|
|||||||
testModel = {
|
testModel = {
|
||||||
composition: [ ID_A, ID_B ],
|
composition: [ ID_A, ID_B ],
|
||||||
someObj: {},
|
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[ID_A] = "some value";
|
||||||
testModel.someObj.someProperty = ID_B;
|
testModel.someObj.someProperty = ID_B;
|
||||||
@@ -242,6 +243,23 @@ define(
|
|||||||
expect(domainObjectBClone.model.someObj.someProperty).toBe(childD_ID);
|
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);
|
||||||
|
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user