Skip to content

Commit

Permalink
Adds ability to interpolate delete operations
Browse files Browse the repository at this point in the history
  • Loading branch information
flovilmart committed May 29, 2016
1 parent f17befd commit 6c200e4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/ParseObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,9 @@ export default class ParseObject {
changes[attr] = new ParseACL(response[attr]);
} else if (attr !== 'objectId') {
changes[attr] = decode(response[attr]);
if (changes[attr] instanceof UnsetOp) {
changes[attr] = undefined;
}
}
}
if (changes.createdAt && !changes.updatedAt) {
Expand Down
19 changes: 19 additions & 0 deletions src/__tests__/ParseObject-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,25 @@ describe('ParseObject', () => {
done();
});
}));

it('interpolates delete operations', asyncHelper((done) => {
CoreManager.getRESTController()._setXHR(
mockXHR([{
status: 200,
response: { objectId: 'newattributes', deletedKey: {__op: 'Delete'} }
}])
);
var o = new ParseObject('Item');
o.save({ key: 'value', deletedKey: 'keyToDelete' }).then(() => {
expect(o.get('key')).toBe('value');
expect(o.get('deletedKey')).toBeUndefined();
o = new ParseObject('Item');
return o.save({ ACL: 'not an acl' });
}).then(null, (error) => {
expect(error.code).toBe(-1);
done();
});
}));

it('can make changes while in the process of a save', asyncHelper((done) => {
var xhr = {
Expand Down

0 comments on commit 6c200e4

Please sign in to comment.