fix: Promise is not being returned in classUpdate method (#5877)
* fix: Set falsy values as default to schema fields * fix: Promise is not being returned in classUpdate method
This commit is contained in:
committed by
Diamond Lewis
parent
f3b84242d7
commit
78c42d97fd
@@ -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 => {
|
it('will fail to create a class if that class was already created by an object', done => {
|
||||||
config.database.loadSchema().then(schema => {
|
config.database.loadSchema().then(schema => {
|
||||||
schema
|
schema
|
||||||
|
|||||||
@@ -768,7 +768,7 @@ export default class SchemaController {
|
|||||||
})
|
})
|
||||||
.then(results => {
|
.then(results => {
|
||||||
enforceFields = results.filter(result => !!result);
|
enforceFields = results.filter(result => !!result);
|
||||||
this.setPermissions(className, classLevelPermissions, newSchema);
|
return this.setPermissions(className, classLevelPermissions, newSchema);
|
||||||
})
|
})
|
||||||
.then(() =>
|
.then(() =>
|
||||||
this._dbAdapter.setIndexesWithSchemaFormat(
|
this._dbAdapter.setIndexesWithSchemaFormat(
|
||||||
|
|||||||
Reference in New Issue
Block a user