Merge pull request #168 from strongloop/feature/new-model-registry-per-app

Make app.models unique per app instance
This commit is contained in:
Miroslav Bajtoš 2014-02-04 11:47:56 -08:00
commit d2adda5f29
3 changed files with 15 additions and 3 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,10 +76,17 @@ 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 () {
var app = this.app = loopback();
app.boot({
app: {
port: 3000,

View File

@ -17,7 +17,7 @@ request = require('supertest');
loopback.User.settings.saltWorkFactor = 4;
beforeEach(function () {
app = loopback();
this.app = app = loopback();
// setup default data sources
loopback.setDefaultDataSourceForType('db', {