File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments