diff --git a/spec/ParseAPI.spec.js b/spec/ParseAPI.spec.js index 1a7eadddf8..a5eeffbfc1 100644 --- a/spec/ParseAPI.spec.js +++ b/spec/ParseAPI.spec.js @@ -618,6 +618,37 @@ describe('miscellaneous', function() { }); }); + it('pointer reassign is working properly (#1288)', (done) => { + Parse.Cloud.beforeSave('GameScore', (req, res) => { + + var obj = req.object; + if (obj.get('point')) { + return res.success(); + } + var TestObject1 = Parse.Object.extend('TestObject1'); + var newObj = new TestObject1({'key1': 1}); + + return newObj.save().then((newObj) => { + obj.set('point' , newObj); + res.success(); + }); + }); + var pointId; + var obj = new Parse.Object('GameScore'); + obj.set('foo', 'bar'); + obj.save().then(() => { + expect(obj.get('point')).not.toBeUndefined(); + pointId = obj.get('point').id; + expect(pointId).not.toBeUndefined(); + obj.set('foo', 'baz'); + return obj.save(); + }).then((obj) => { + expect(obj.get('point').id).toEqual(pointId); + Parse.Cloud._removeHook("Triggers", "beforeSave", "GameScore"); + done(); + }) + }); + it('test afterSave get full object on create and update', function(done) { var triggerTime = 0; // Register a mock beforeSave hook diff --git a/src/RestWrite.js b/src/RestWrite.js index e18c660d96..0bdaac5b9f 100644 --- a/src/RestWrite.js +++ b/src/RestWrite.js @@ -169,6 +169,7 @@ RestWrite.prototype.runBeforeTrigger = function() { if (this.query && this.query.objectId) { delete this.data.objectId } + return this.validateSchema(); } }); }; @@ -302,7 +303,7 @@ RestWrite.prototype.handleAuthData = function(authData) { 'this auth is already used'); } } - } + } return Promise.resolve(); }); }