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;
|
||||
|
||||
if(typeof dataSource === 'string') {
|
||||
dataSource = app.dataSources[dataSource];
|
||||
}
|
||||
if(dataSource) {
|
||||
if(typeof dataSource === 'string') {
|
||||
dataSource = app.dataSources[dataSource];
|
||||
}
|
||||
|
||||
assert(dataSource instanceof DataSource,
|
||||
ModelCtor.modelName + ' is referencing a dataSource that does not exist: "' +
|
||||
config.dataSource +'"');
|
||||
assert(dataSource instanceof DataSource,
|
||||
ModelCtor.modelName + ' is referencing a dataSource that does not exist: "' +
|
||||
config.dataSource +'"');
|
||||
}
|
||||
|
||||
config = extend({}, config);
|
||||
config.dataSource = dataSource;
|
||||
|
|
|
@ -69,6 +69,10 @@ describe('app', function() {
|
|||
request(app).get('/colors').expect(200, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('should not require dataSource', function() {
|
||||
app.model('MyTestModel', {});
|
||||
});
|
||||
});
|
||||
|
||||
describe('app.model(name, config)', function () {
|
||||
|
|
Loading…
Reference in New Issue