Skip to content

Commit 91de750

Browse files
committed
🎉 fixes #1288
* ⚡ regression test for #1288 * 🎉 fixes #1288
1 parent ec6a397 commit 91de750

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

spec/ParseAPI.spec.js

+31
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,37 @@ describe('miscellaneous', function() {
618618
});
619619
});
620620

621+
it('pointer reassign is working properly (#1288)', (done) => {
622+
Parse.Cloud.beforeSave('GameScore', (req, res) => {
623+
624+
var obj = req.object;
625+
if (obj.get('point')) {
626+
return res.success();
627+
}
628+
var TestObject1 = Parse.Object.extend('TestObject1');
629+
var newObj = new TestObject1({'key1': 1});
630+
631+
return newObj.save().then((newObj) => {
632+
obj.set('point' , newObj);
633+
res.success();
634+
});
635+
});
636+
var pointId;
637+
var obj = new Parse.Object('GameScore');
638+
obj.set('foo', 'bar');
639+
obj.save().then(() => {
640+
expect(obj.get('point')).not.toBeUndefined();
641+
pointId = obj.get('point').id;
642+
expect(pointId).not.toBeUndefined();
643+
obj.set('foo', 'baz');
644+
return obj.save();
645+
}).then((obj) => {
646+
expect(obj.get('point').id).toEqual(pointId);
647+
Parse.Cloud._removeHook("Triggers", "beforeSave", "GameScore");
648+
done();
649+
})
650+
});
651+
621652
it('test afterSave get full object on create and update', function(done) {
622653
var triggerTime = 0;
623654
// Register a mock beforeSave hook

src/RestWrite.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ RestWrite.prototype.runBeforeTrigger = function() {
169169
if (this.query && this.query.objectId) {
170170
delete this.data.objectId
171171
}
172+
return this.validateSchema();
172173
}
173174
});
174175
};
@@ -302,7 +303,7 @@ RestWrite.prototype.handleAuthData = function(authData) {
302303
'this auth is already used');
303304
}
304305
}
305-
}
306+
}
306307
return Promise.resolve();
307308
});
308309
}

0 commit comments

Comments
 (0)