@@ -712,7 +712,7 @@ describe('Cloud Code', () => {
712712 done ( ) ;
713713 } ) ;
714714 } ) ;
715-
715+
716716 it ( 'beforeSave change propagates through the afterSave #1931' , ( done ) => {
717717 Parse . Cloud . beforeSave ( 'ChangingObject' , function ( request , response ) {
718718 request . object . unset ( 'file' ) ;
@@ -1044,7 +1044,7 @@ describe('Cloud Code', () => {
10441044 res . success ( ) ;
10451045 } ) ;
10461046 } ) . not . toThrow ( ) ;
1047-
1047+
10481048 rp . post ( {
10491049 url : 'http://localhost:8378/1/jobs/myJob' ,
10501050 headers : {
@@ -1065,7 +1065,7 @@ describe('Cloud Code', () => {
10651065 res . success ( ) ;
10661066 } ) ;
10671067 } ) . not . toThrow ( ) ;
1068-
1068+
10691069 rp . post ( {
10701070 url : 'http://localhost:8378/1/jobs/myJob' ,
10711071 headers : {
@@ -1094,7 +1094,7 @@ describe('Cloud Code', () => {
10941094 done ( ) ;
10951095 } ) ;
10961096 } ) . not . toThrow ( ) ;
1097-
1097+
10981098 rp . post ( {
10991099 url : 'http://localhost:8378/1/jobs/myJob' ,
11001100 headers : {
@@ -1121,7 +1121,7 @@ describe('Cloud Code', () => {
11211121 done ( ) ;
11221122 } ) ;
11231123 } ) . not . toThrow ( ) ;
1124-
1124+
11251125 rp . post ( {
11261126 url : `http://${ Parse . applicationId } :${ Parse . masterKey } @localhost:8378/1/jobs/myJob` ,
11271127 } ) . then ( ( ) => {
@@ -1152,7 +1152,7 @@ describe('Cloud Code', () => {
11521152 done ( ) ;
11531153 } ) ;
11541154 } ) ;
1155-
1155+
11561156 rp . post ( {
11571157 url : 'http://localhost:8378/1/jobs/myJob' ,
11581158 headers : {
@@ -1179,7 +1179,7 @@ describe('Cloud Code', () => {
11791179 done ( ) ;
11801180 } ) ;
11811181 } ) ;
1182-
1182+
11831183 rp . post ( {
11841184 url : 'http://localhost:8378/1/jobs/myJob' ,
11851185 headers : {
@@ -1434,5 +1434,40 @@ describe('afterFind hooks', () => {
14341434 } ) ;
14351435 } ) ;
14361436
1437- } ) ;
1437+ it ( 'should alter select' , ( done ) => {
1438+ Parse . Cloud . beforeFind ( 'MyObject' , ( req ) => {
1439+ req . query . select ( 'white' ) ;
1440+ return req . query ;
1441+ } ) ;
1442+
1443+ const obj0 = new Parse . Object ( 'MyObject' )
1444+ . set ( 'white' , true )
1445+ . set ( 'black' , true ) ;
1446+ obj0 . save ( )
1447+ . then ( ( ) => {
1448+ new Parse . Query ( 'MyObject' )
1449+ . first ( )
1450+ . then ( result => {
1451+ expect ( result . get ( 'white' ) ) . toBe ( true ) ;
1452+ expect ( result . get ( 'black' ) ) . toBe ( undefined ) ;
1453+ done ( ) ;
1454+ } ) ;
1455+ } ) ;
1456+ } ) ;
14381457
1458+ it ( 'should not alter select' , ( done ) => {
1459+ const obj0 = new Parse . Object ( 'MyObject' )
1460+ . set ( 'white' , true )
1461+ . set ( 'black' , true ) ;
1462+ obj0 . save ( )
1463+ . then ( ( ) => {
1464+ new Parse . Query ( 'MyObject' )
1465+ . first ( )
1466+ . then ( result => {
1467+ expect ( result . get ( 'white' ) ) . toBe ( true ) ;
1468+ expect ( result . get ( 'black' ) ) . toBe ( true ) ;
1469+ done ( ) ;
1470+ } ) ;
1471+ } ) ;
1472+ } ) ;
1473+ } ) ;
0 commit comments