Make app.models unique per app instance
Remove a source of confusion in unit-tests.
This commit is contained in:
parent
4a076f13fd
commit
b13ff35697
|
@ -57,6 +57,11 @@ function createApplication() {
|
||||||
|
|
||||||
utils.merge(app, proto);
|
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;
|
return app;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 () {
|
describe('app.boot([options])', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
app.boot({
|
app.boot({
|
||||||
|
|
Loading…
Reference in New Issue