diff --git a/spec/Schema.spec.js b/spec/Schema.spec.js index cf73927274..56cf97f363 100644 --- a/spec/Schema.spec.js +++ b/spec/Schema.spec.js @@ -426,6 +426,42 @@ describe('SchemaController', () => { }); }); + it('can update class level permission', done => { + const newLevelPermissions = { + find: {}, + get: { '*': true }, + count: {}, + create: { '*': true }, + update: {}, + delete: { '*': true }, + addField: {}, + protectedFields: { '*': [] }, + }; + config.database.loadSchema().then(schema => { + schema + .validateObject('NewClass', { foo: 2 }) + .then(() => schema.reloadData()) + .then(() => + schema.updateClass( + 'NewClass', + {}, + newLevelPermissions, + {}, + config.database + ) + ) + .then(actualSchema => { + expect(dd(actualSchema.classLevelPermissions, newLevelPermissions)).toEqual(undefined); + done(); + }) + .catch(error => { + console.trace(error); + done(); + fail('Error creating class: ' + JSON.stringify(error)); + }); + }); + }); + it('will fail to create a class if that class was already created by an object', done => { config.database.loadSchema().then(schema => { schema diff --git a/src/Controllers/SchemaController.js b/src/Controllers/SchemaController.js index aa64ef871d..ac76ca1ad0 100644 --- a/src/Controllers/SchemaController.js +++ b/src/Controllers/SchemaController.js @@ -768,7 +768,7 @@ export default class SchemaController { }) .then(results => { enforceFields = results.filter(result => !!result); - this.setPermissions(className, classLevelPermissions, newSchema); + return this.setPermissions(className, classLevelPermissions, newSchema); }) .then(() => this._dbAdapter.setIndexesWithSchemaFormat(