Skip to content

Commit

Permalink
🎉 fixes #1288
Browse files Browse the repository at this point in the history
* ⚡ regression test for #1288

* 🎉 fixes #1288
  • Loading branch information
flovilmart committed Apr 4, 2016
1 parent ec6a397 commit 91de750
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
31 changes: 31 additions & 0 deletions spec/ParseAPI.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/RestWrite.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ RestWrite.prototype.runBeforeTrigger = function() {
if (this.query && this.query.objectId) {
delete this.data.objectId
}
return this.validateSchema();
}
});
};
Expand Down Expand Up @@ -302,7 +303,7 @@ RestWrite.prototype.handleAuthData = function(authData) {
'this auth is already used');
}
}
}
}
return Promise.resolve();
});
}
Expand Down

0 comments on commit 91de750

Please sign in to comment.