@@ -1408,10 +1408,67 @@ describe('miscellaneous', function() {
1408
1408
uri : 'http://localhost:8378/1/classes/TestObject' ,
1409
1409
json : true
1410
1410
} ) . then ( body => {
1411
- fail ( 'Should not succeed' )
1411
+ fail ( 'Should not succeed' ) ;
1412
1412
} ) . catch ( err => {
1413
1413
expect ( err . error . error ) . toEqual ( 'unauthorized: master key is required' ) ;
1414
1414
done ( ) ;
1415
1415
} ) ;
1416
1416
} ) ;
1417
+
1418
+ it ( 'purge all objects in _Role also purge cache' , ( done ) => {
1419
+ let headers = {
1420
+ 'Content-Type' : 'application/json' ,
1421
+ 'X-Parse-Application-Id' : 'test' ,
1422
+ 'X-Parse-Master-Key' : 'test'
1423
+ } ;
1424
+ var user , object ;
1425
+ createTestUser ( ) . then ( ( x ) => {
1426
+ user = x ;
1427
+ let acl = new Parse . ACL ( ) ;
1428
+ acl . setPublicReadAccess ( true ) ;
1429
+ acl . setPublicWriteAccess ( false ) ;
1430
+ let role = new Parse . Object ( '_Role' ) ;
1431
+ role . set ( 'name' , 'TestRole' ) ;
1432
+ role . setACL ( acl ) ;
1433
+ let users = role . relation ( 'users' ) ;
1434
+ users . add ( user ) ;
1435
+ return role . save ( { } , { useMasterKey : true } ) ;
1436
+ } ) . then ( ( x ) => {
1437
+ let query = new Parse . Query ( '_Role' ) ;
1438
+ return query . find ( { useMasterKey : true } ) ;
1439
+ } ) . then ( ( x ) => {
1440
+ expect ( x . length ) . toEqual ( 1 ) ;
1441
+ let relation = x [ 0 ] . relation ( 'users' ) . query ( ) ;
1442
+ return relation . first ( { useMasterKey : true } ) ;
1443
+ } ) . then ( ( x ) => {
1444
+ expect ( x . id ) . toEqual ( user . id ) ;
1445
+ object = new Parse . Object ( 'TestObject' ) ;
1446
+ let acl = new Parse . ACL ( ) ;
1447
+ acl . setPublicReadAccess ( false ) ;
1448
+ acl . setPublicWriteAccess ( false ) ;
1449
+ acl . setRoleReadAccess ( 'TestRole' , true ) ;
1450
+ acl . setRoleWriteAccess ( 'TestRole' , true ) ;
1451
+ object . setACL ( acl ) ;
1452
+ return object . save ( ) ;
1453
+ } ) . then ( ( x ) => {
1454
+ let query = new Parse . Query ( 'TestObject' ) ;
1455
+ return query . find ( { sessionToken : user . getSessionToken ( ) } ) ;
1456
+ } ) . then ( ( x ) => {
1457
+ expect ( x . length ) . toEqual ( 1 ) ;
1458
+ return rp ( {
1459
+ method : 'DELETE' ,
1460
+ headers : headers ,
1461
+ uri : 'http://localhost:8378/1/classes/_Role' ,
1462
+ json : true
1463
+ } ) ;
1464
+ } ) . then ( ( x ) => {
1465
+ let query = new Parse . Query ( 'TestObject' ) ;
1466
+ return query . get ( object . id , { sessionToken : user . getSessionToken ( ) } ) ;
1467
+ } ) . then ( ( x ) => {
1468
+ fail ( 'Should not succeed' ) ;
1469
+ } , ( e ) => {
1470
+ expect ( e . code ) . toEqual ( Parse . Error . OBJECT_NOT_FOUND ) ;
1471
+ done ( ) ;
1472
+ } ) ;
1473
+ } ) ;
1417
1474
} ) ;
0 commit comments