Merge pull request #2687 from strongloop/backport/set-datasource-app-2x

Make the app instance available to connectors
This commit is contained in:
Miroslav Bajtoš 2016-08-29 15:15:26 +02:00 committed by GitHub
commit 5f74e74ea0
2 changed files with 7 additions and 0 deletions

View File

@ -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) {

View File

@ -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() {