Fix checking existent class for allowClientClassCreation (#2051)

This commit is contained in:
Marco Cheung
2016-06-14 00:21:52 +08:00
committed by Drew
parent 2cc1b0cfa9
commit 0ec78d478b
4 changed files with 49 additions and 20 deletions

View File

@@ -91,6 +91,21 @@ describe('rest create', () => {
});
});
it('handles create on existent class when disabled client class creation', (done) => {
var customConfig = Object.assign({}, config, {allowClientClassCreation: false});
config.database.loadSchema()
.then(schema => schema.addClassIfNotExists('ClientClassCreation', {}))
.then(actualSchema => {
expect(actualSchema.className).toEqual('ClientClassCreation');
return rest.create(customConfig, auth.nobody(customConfig), 'ClientClassCreation', {});
})
.then(() => {
done();
}, err => {
fail('Should not throw error')
});
});
it('handles user signup', (done) => {
var user = {
username: 'asdf',

View File

@@ -145,6 +145,22 @@ describe('rest query', () => {
});
});
it('query existent class when disabled client class creation', (done) => {
var customConfig = Object.assign({}, config, {allowClientClassCreation: false});
config.database.loadSchema()
.then(schema => schema.addClassIfNotExists('ClientClassCreation', {}))
.then(actualSchema => {
expect(actualSchema.className).toEqual('ClientClassCreation');
return rest.find(customConfig, auth.nobody(customConfig), 'ClientClassCreation', {});
})
.then((result) => {
expect(result.results.length).toEqual(0);
done();
}, err => {
fail('Should not throw error')
});
});
it('query with wrongly encoded parameter', (done) => {
rest.create(config, nobody, 'TestParameterEncode', {foo: 'bar'}
).then(() => {