Only validate dataSource when defined (Fixes #482)

This commit is contained in:
Ritchie Martori 2014-08-20 16:05:45 -07:00 committed by Miroslav Bajtoš
parent 50e1f350aa
commit 7dde6466e5
2 changed files with 12 additions and 6 deletions

View File

@ -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;

View File

@ -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 () {