Only validate dataSource when defined (Fixes #482)
This commit is contained in:
parent
50e1f350aa
commit
7dde6466e5
|
@ -390,6 +390,7 @@ function configureModel(ModelCtor, config, app) {
|
|||
|
||||
var dataSource = config.dataSource;
|
||||
|
||||
if(dataSource) {
|
||||
if(typeof dataSource === 'string') {
|
||||
dataSource = app.dataSources[dataSource];
|
||||
}
|
||||
|
@ -397,6 +398,7 @@ function configureModel(ModelCtor, config, app) {
|
|||
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