Fixes SchemaController data for Volatile Classes (#3171)

* Reproduction for the issue

* Ensures Volatile classes and other schema share the same structure
This commit is contained in:
Florent Vilmart
2016-12-06 16:42:54 -05:00
committed by GitHub
parent 8111c3338e
commit 2e569ca7dd
2 changed files with 40 additions and 6 deletions

View File

@@ -880,6 +880,38 @@ describe('SchemaController', () => {
done();
});
});
it('properly handles volatile _Schemas', done => {
function validateSchemaStructure(schema) {
expect(schema.hasOwnProperty('className')).toBe(true);
expect(schema.hasOwnProperty('fields')).toBe(true);
expect(schema.hasOwnProperty('classLevelPermissions')).toBe(true);
}
function validateSchemaDataStructure(schemaData) {
Object.keys(schemaData).forEach(className => {
let schema = schemaData[className];
// Hooks has className...
if (className != '_Hooks') {
expect(schema.hasOwnProperty('className')).toBe(false);
}
expect(schema.hasOwnProperty('fields')).toBe(false);
expect(schema.hasOwnProperty('classLevelPermissions')).toBe(false);
});
}
let schema;
config.database.loadSchema().then(s => {
schema = s;
return schema.getOneSchema('_User', false);
}).then(userSchema => {
validateSchemaStructure(userSchema);
validateSchemaDataStructure(schema.data);
return schema.getOneSchema('_PushStatus', true);
}).then(pushStatusSchema => {
validateSchemaStructure(pushStatusSchema);
validateSchemaDataStructure(schema.data);
done();
});
});
});
describe('Class Level Permissions for requiredAuth', () => {