@@ -929,6 +929,55 @@ describe('Installations', () => {
929929 } ) ;
930930 } ) ;
931931
932+ it ( 'should properly handle installation save #2780' , done => {
933+ let installId = '12345678-abcd-abcd-abcd-123456789abc' ;
934+ let device = 'android' ;
935+ let input = {
936+ 'installationId' : installId ,
937+ 'deviceType' : device
938+ } ;
939+ rest . create ( config , auth . nobody ( config ) , '_Installation' , input ) . then ( ( ) => {
940+ let query = new Parse . Query ( Parse . Installation ) ;
941+ query . equalTo ( 'installationId' , installId ) ;
942+ query . first ( { useMasterKey : true } ) . then ( ( installation ) => {
943+ return installation . save ( {
944+ key : 'value'
945+ } , { useMasterKey : true } ) ;
946+ } ) . then ( ( ) => {
947+ done ( ) ;
948+ } , ( err ) => {
949+ jfail ( err )
950+ done ( ) ;
951+ } ) ;
952+ } ) ;
953+ } ) ;
954+
955+ it ( 'should properly reject updating installationId' , done => {
956+ let installId = '12345678-abcd-abcd-abcd-123456789abc' ;
957+ let device = 'android' ;
958+ let input = {
959+ 'installationId' : installId ,
960+ 'deviceType' : device
961+ } ;
962+ rest . create ( config , auth . nobody ( config ) , '_Installation' , input ) . then ( ( ) => {
963+ let query = new Parse . Query ( Parse . Installation ) ;
964+ query . equalTo ( 'installationId' , installId ) ;
965+ query . first ( { useMasterKey : true } ) . then ( ( installation ) => {
966+ return installation . save ( {
967+ key : 'value' ,
968+ installationId : '22222222-abcd-abcd-abcd-123456789abc'
969+ } , { useMasterKey : true } ) ;
970+ } ) . then ( ( ) => {
971+ fail ( 'should not succeed' ) ;
972+ done ( ) ;
973+ } , ( err ) => {
974+ expect ( err . code ) . toBe ( 136 ) ;
975+ expect ( err . message ) . toBe ( 'installationId may not be changed in this operation' ) ;
976+ done ( ) ;
977+ } ) ;
978+ } ) ;
979+ } ) ;
980+
932981 // TODO: Look at additional tests from installation_collection_test.go:882
933982 // TODO: Do we need to support _tombstone disabling of installations?
934983 // TODO: Test deletion, badge increments
0 commit comments