Merge pull request #168 from strongloop/feature/new-model-registry-per-app
Make app.models unique per app instance
This commit is contained in:
commit
d2adda5f29
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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', {
|
||||
|
|
Loading…
Reference in New Issue