Only validate dataSource when defined (Fixes #482)
This commit is contained in:
parent
50e1f350aa
commit
7dde6466e5
|
@ -390,13 +390,15 @@ function configureModel(ModelCtor, config, app) {
|
||||||
|
|
||||||
var dataSource = config.dataSource;
|
var dataSource = config.dataSource;
|
||||||
|
|
||||||
if(typeof dataSource === 'string') {
|
if(dataSource) {
|
||||||
dataSource = app.dataSources[dataSource];
|
if(typeof dataSource === 'string') {
|
||||||
}
|
dataSource = app.dataSources[dataSource];
|
||||||
|
}
|
||||||
|
|
||||||
assert(dataSource instanceof DataSource,
|
assert(dataSource instanceof DataSource,
|
||||||
ModelCtor.modelName + ' is referencing a dataSource that does not exist: "' +
|
ModelCtor.modelName + ' is referencing a dataSource that does not exist: "' +
|
||||||
config.dataSource +'"');
|
config.dataSource +'"');
|
||||||
|
}
|
||||||
|
|
||||||
config = extend({}, config);
|
config = extend({}, config);
|
||||||
config.dataSource = dataSource;
|
config.dataSource = dataSource;
|
||||||
|
|
|
@ -69,6 +69,10 @@ describe('app', function() {
|
||||||
request(app).get('/colors').expect(200, done);
|
request(app).get('/colors').expect(200, done);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not require dataSource', function() {
|
||||||
|
app.model('MyTestModel', {});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('app.model(name, config)', function () {
|
describe('app.model(name, config)', function () {
|
||||||
|
|
Loading…
Reference in New Issue