Properly handle return values in beforeSave (#5228)

* added failing test case to CloudCode.spec.js

a possible bug found where beforeSave does not apply changes to request
object if the beforeSave hook ends with 'true' returned

* moddified triggers to return null when beforeSave
also changed test cases to be more descriptive + added extra test case that returns promise in the beforeSave

* address original issue

* Revert "address original issue"

This reverts commit e01c57d1de5c4b2fe21e9ebd590211d21330cdda.

* fix promises and tests

* Add a test to verify that a failed beforeChange hook will
prevent updating the object.
This commit is contained in:
Guido Ruiz
2019-03-14 14:17:29 -04:00
committed by Diamond Lewis
parent 8622e5c378
commit bf033becbd
3 changed files with 76 additions and 1 deletions

View File

@@ -101,7 +101,7 @@ describe('Cloud Code Logger', () => {
expect(cloudTriggerMessage[0]).toBe('info');
expect(cloudTriggerMessage[2].triggerType).toEqual('beforeSave');
expect(cloudTriggerMessage[1]).toMatch(
/beforeSave triggered for MyObject for user [^ ]*\n {2}Input: {}\n {2}Result: {}/
/beforeSave triggered for MyObject for user [^ ]*\n {2}Input: {}\n {2}Result: {"object":{}}/
);
expect(cloudTriggerMessage[2].user).toBe(user.id);
expect(errorMessage[0]).toBe('error');