Merge pull request #2687 from strongloop/backport/set-datasource-app-2x
Make the app instance available to connectors
This commit is contained in:
commit
5f74e74ea0
|
@ -236,6 +236,7 @@ app.dataSource = function(name, config) {
|
|||
this.dataSources[name] =
|
||||
this.dataSources[classify(name)] =
|
||||
this.dataSources[camelize(name)] = ds;
|
||||
ds.app = this;
|
||||
return ds;
|
||||
} catch (err) {
|
||||
if (err.message) {
|
||||
|
|
|
@ -820,6 +820,12 @@ describe('app', function() {
|
|||
app.dataSource('bad-ds', { connector: 'throwing' });
|
||||
}).to.throw(/bad-ds.*throwing/);
|
||||
});
|
||||
|
||||
it('adds app reference to the data source object', function() {
|
||||
app.dataSource('ds', { connector: 'memory' });
|
||||
expect(app.datasources.ds.app).to.not.equal(undefined);
|
||||
expect(app.datasources.ds.app).to.equal(app);
|
||||
});
|
||||
});
|
||||
|
||||
describe.onServer('listen()', function() {
|
||||
|
|
Loading…
Reference in New Issue