fix(Users): Makes sure verifying emails triggers hooks and liveQuery (#3851)
* Use RestWrite when verifying emails so hooks are called (as master) * Fixes tests for postgres * nit * Makes rest.update support a full where instead of objectId * Use rest.update to guaranteed proper beforeSave and liveQuery calls
This commit is contained in:
@@ -339,11 +339,11 @@ describe('Installations', () => {
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {}, {}))
|
||||
.then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
var id = results[0].objectId;
|
||||
var objectId = results[0].objectId;
|
||||
var update = {
|
||||
'channels': ['baz']
|
||||
};
|
||||
return rest.update(config, auth.nobody(config), '_Installation', id, update);
|
||||
return rest.update(config, auth.nobody(config), '_Installation', { objectId }, update);
|
||||
})
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {}, {}))
|
||||
.then(results => {
|
||||
@@ -370,7 +370,7 @@ describe('Installations', () => {
|
||||
.then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
input = { 'installationId': installId2 };
|
||||
return rest.update(config, auth.nobody(config), '_Installation', results[0].objectId, input);
|
||||
return rest.update(config, auth.nobody(config), '_Installation', { objectId: results[0].objectId }, input);
|
||||
}).then(() => {
|
||||
fail('Updating the installation should have failed.');
|
||||
done();
|
||||
@@ -393,7 +393,7 @@ describe('Installations', () => {
|
||||
.then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
input = { 'deviceToken': b };
|
||||
return rest.update(config, auth.nobody(config), '_Installation', results[0].objectId, input);
|
||||
return rest.update(config, auth.nobody(config), '_Installation', { objectId: results[0].objectId }, input);
|
||||
}).then(() => {
|
||||
fail('Updating the installation should have failed.');
|
||||
}).catch((error) => {
|
||||
@@ -421,7 +421,7 @@ describe('Installations', () => {
|
||||
'deviceToken': u,
|
||||
'deviceType': 'ios'
|
||||
};
|
||||
return rest.update(config, auth.nobody(config), '_Installation', results[0].objectId, input);
|
||||
return rest.update(config, auth.nobody(config), '_Installation', { objectId: results[0].objectId }, input);
|
||||
})
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {}, {}))
|
||||
.then(results => {
|
||||
@@ -448,7 +448,7 @@ describe('Installations', () => {
|
||||
input = {
|
||||
'deviceType': 'ios'
|
||||
};
|
||||
return rest.update(config, auth.nobody(config), '_Installation', results[0].objectId, input);
|
||||
return rest.update(config, auth.nobody(config), '_Installation', { objectId: results[0].objectId }, input);
|
||||
}).then(() => {
|
||||
fail('Should not have been able to update Installation.');
|
||||
done();
|
||||
@@ -472,7 +472,7 @@ describe('Installations', () => {
|
||||
input = {
|
||||
'custom': 'allowed'
|
||||
};
|
||||
return rest.update(config, auth.nobody(config), '_Installation', results[0].objectId, input);
|
||||
return rest.update(config, auth.nobody(config), '_Installation', { objectId: results[0].objectId }, input);
|
||||
})
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {}, {}))
|
||||
.then(results => {
|
||||
@@ -514,7 +514,7 @@ describe('Installations', () => {
|
||||
'objectId': secondObject.objectId,
|
||||
'deviceToken': t
|
||||
};
|
||||
return rest.update(config, auth.nobody(config), '_Installation', secondObject.objectId, input);
|
||||
return rest.update(config, auth.nobody(config), '_Installation', { objectId: secondObject.objectId }, input);
|
||||
})
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {objectId: firstObject.objectId}, {}))
|
||||
.then(results => {
|
||||
@@ -562,7 +562,7 @@ describe('Installations', () => {
|
||||
'installationId': installId2,
|
||||
'deviceToken': t
|
||||
};
|
||||
return rest.update(config, auth.nobody(config), '_Installation', secondObject.objectId, input);
|
||||
return rest.update(config, auth.nobody(config), '_Installation', { objectId: secondObject.objectId }, input);
|
||||
})
|
||||
.then(() => delay(100))
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {objectId: firstObject.objectId}, {}))
|
||||
@@ -619,7 +619,7 @@ describe('Installations', () => {
|
||||
'deviceToken': t,
|
||||
'channels': []
|
||||
};
|
||||
return rest.update(config, auth.nobody(config), '_Installation', results[0].objectId, input);
|
||||
return rest.update(config, auth.nobody(config), '_Installation', { objectId: results[0].objectId }, input);
|
||||
})
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {}, {}))
|
||||
.then(results => {
|
||||
@@ -657,7 +657,7 @@ describe('Installations', () => {
|
||||
'installationId': installId,
|
||||
'deviceType': 'ios'
|
||||
};
|
||||
return rest.update(config, auth.nobody(config), '_Installation', results[0].objectId, input);
|
||||
return rest.update(config, auth.nobody(config), '_Installation', { objectId: results[0].objectId }, input);
|
||||
})
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {}, {}))
|
||||
.then(results => {
|
||||
@@ -699,7 +699,7 @@ describe('Installations', () => {
|
||||
'amount': 1
|
||||
}
|
||||
};
|
||||
return rest.update(config, auth.nobody(config), '_Installation', results[0].objectId, input);
|
||||
return rest.update(config, auth.nobody(config), '_Installation', { objectId: results[0].objectId }, input);
|
||||
})
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, {}, {}))
|
||||
.then(results => {
|
||||
@@ -744,7 +744,7 @@ describe('Installations', () => {
|
||||
'deviceToken': t,
|
||||
'deviceType': 'ios'
|
||||
};
|
||||
return rest.update(config, auth.nobody(config), '_Installation', installObj.objectId, input);
|
||||
return rest.update(config, auth.nobody(config), '_Installation', { objectId: installObj.objectId }, input);
|
||||
})
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, { objectId: tokenObj.objectId }, {}))
|
||||
.then(results => {
|
||||
@@ -791,7 +791,7 @@ describe('Installations', () => {
|
||||
'amount': 1
|
||||
}
|
||||
};
|
||||
return rest.update(config, auth.nobody(config), '_Installation', installObj.objectId, input);
|
||||
return rest.update(config, auth.nobody(config), '_Installation', { objectId: installObj.objectId }, input);
|
||||
})
|
||||
.then(() => database.adapter.find('_Installation', installationSchema, { objectId: tokenObj.objectId }, {}))
|
||||
.then(results => {
|
||||
|
||||
@@ -64,7 +64,7 @@ describe('rest create', () => {
|
||||
expect(mob.subdoc.wu).toBe('tan');
|
||||
expect(typeof mob.objectId).toEqual('string');
|
||||
const obj = { 'subdoc.wu': 'clan' };
|
||||
return rest.update(config, auth.nobody(config), 'MyClass', mob.objectId, obj)
|
||||
return rest.update(config, auth.nobody(config), 'MyClass', { objectId: mob.objectId }, obj)
|
||||
})
|
||||
.then(() => database.adapter.find('MyClass', { fields: {} }, {}, {}))
|
||||
.then(results => {
|
||||
@@ -195,7 +195,7 @@ describe('rest create', () => {
|
||||
objectId = r.response.objectId;
|
||||
return auth.getAuthForSessionToken({config, sessionToken: r.response.sessionToken })
|
||||
}).then((sessionAuth) => {
|
||||
return rest.update(config, sessionAuth, '_User', objectId, updatedData);
|
||||
return rest.update(config, sessionAuth, '_User', { objectId }, updatedData);
|
||||
}).then(() => {
|
||||
return Parse.User.logOut().then(() => {
|
||||
return Parse.User.logIn('hello', 'world');
|
||||
@@ -435,7 +435,7 @@ describe('rest update', () => {
|
||||
createdAt: {__type: "Date", iso: newCreatedAt}, // should be ignored
|
||||
};
|
||||
|
||||
return rest.update(config, nobody, className, objectId, restObject).then(() => {
|
||||
return rest.update(config, nobody, className, { objectId }, restObject).then(() => {
|
||||
const restWhere = {
|
||||
objectId: objectId,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user