Merge pull request #283 from strongloop/feature/single-datasource-registry-per-app-instance
Make app.datasources unique per app instance
This commit is contained in:
commit
7508337d56
|
@ -76,6 +76,9 @@ function createApplication() {
|
||||||
return proto.models.apply(this, arguments);
|
return proto.models.apply(this, arguments);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Create a new instance of datasources registry per each app instance
|
||||||
|
app.datasources = app.dataSources = {};
|
||||||
|
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,6 +111,7 @@ describe('app', function() {
|
||||||
|
|
||||||
describe('app.models', function() {
|
describe('app.models', function() {
|
||||||
it('is unique per app instance', function() {
|
it('is unique per app instance', function() {
|
||||||
|
app.dataSource('db', { connector: 'memory' });
|
||||||
var Color = app.model('Color', { dataSource: 'db' });
|
var Color = app.model('Color', { dataSource: 'db' });
|
||||||
expect(app.models.Color).to.equal(Color);
|
expect(app.models.Color).to.equal(Color);
|
||||||
var anotherApp = loopback();
|
var anotherApp = loopback();
|
||||||
|
@ -118,6 +119,15 @@ describe('app', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('app.dataSources', function() {
|
||||||
|
it('is unique per app instance', function() {
|
||||||
|
app.dataSource('ds', { connector: 'memory' });
|
||||||
|
expect(app.datasources.ds).to.not.equal(undefined);
|
||||||
|
var anotherApp = loopback();
|
||||||
|
expect(anotherApp.datasources.ds).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