Make app.models unique per app instance

Remove a source of confusion in unit-tests.
This commit is contained in:
Miroslav Bajtoš 2014-02-04 20:28:19 +01:00
parent 4a076f13fd
commit b13ff35697
2 changed files with 14 additions and 0 deletions

View File

@ -57,6 +57,11 @@ function createApplication() {
utils.merge(app, proto);
// Create a new instance of models registry per each app instance
app.models = function() {
return proto.models.apply(this, arguments);
};
return app;
}

View File

@ -76,6 +76,15 @@ describe('app', function() {
});
});
describe('app.models', function() {
it('is unique per app instance', function() {
var Color = app.model('Color', { dataSource: 'db' });
expect(app.models.Color).to.equal(Color);
var anotherApp = loopback();
expect(anotherApp.models.Color).to.equal(undefined);
});
});
describe('app.boot([options])', function () {
beforeEach(function () {
app.boot({