App config settings are now available from app.get()
This commit is contained in:
parent
b62b8fa47d
commit
ea7c9216d7
|
@ -248,6 +248,13 @@ app.boot = function(options) {
|
|||
app.set('port', appConfig.port);
|
||||
}
|
||||
|
||||
for(var configKey in appConfig) {
|
||||
var cur = app.get(configKey);
|
||||
if(cur === undefined || cur === null) {
|
||||
app.set(configKey, appConfig[configKey]);
|
||||
}
|
||||
}
|
||||
|
||||
// instantiate data sources
|
||||
forEachKeyedObject(dataSourceConfig, function(key, obj) {
|
||||
app.dataSource(key, obj);
|
||||
|
|
|
@ -35,7 +35,8 @@
|
|||
"loopback-datasource-juggler": "~1.2.0",
|
||||
"mocha": "~1.14.0",
|
||||
"strong-task-emitter": "0.0.x",
|
||||
"supertest": "~0.8.1"
|
||||
"supertest": "~0.8.1",
|
||||
"chai": "~1.8.1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
|
@ -31,21 +31,7 @@ describe('app', function() {
|
|||
|
||||
assert(f instanceof loopback.Model);
|
||||
});
|
||||
})
|
||||
|
||||
// describe('app.models()', function() {
|
||||
// it("Get the app's exposed models", function() {
|
||||
// var app = loopback();
|
||||
// var models = app.models();
|
||||
|
||||
// models.forEach(function(m) {
|
||||
// console.log(m.modelName);
|
||||
// })
|
||||
|
||||
// assert.equal(models.length, 1);
|
||||
// assert.equal(models[0].modelName, 'color');
|
||||
// });
|
||||
// });
|
||||
});
|
||||
|
||||
describe('app.boot([options])', function () {
|
||||
beforeEach(function () {
|
||||
|
@ -54,7 +40,9 @@ describe('app', function() {
|
|||
app.boot({
|
||||
app: {
|
||||
port: 3000,
|
||||
host: '127.0.0.1'
|
||||
host: '127.0.0.1',
|
||||
foo: {bar: 'bat'},
|
||||
baz: true
|
||||
},
|
||||
models: {
|
||||
'foo-bar-bat-baz': {
|
||||
|
@ -72,11 +60,21 @@ describe('app', function() {
|
|||
});
|
||||
});
|
||||
|
||||
it('Load configuration', function () {
|
||||
it('should have port setting', function () {
|
||||
assert.equal(this.app.get('port'), 3000);
|
||||
});
|
||||
|
||||
it('should have host setting', function() {
|
||||
assert.equal(this.app.get('host'), '127.0.0.1');
|
||||
});
|
||||
|
||||
it('should have other settings', function () {
|
||||
expect(this.app.get('foo')).to.eql({
|
||||
bar: 'bat'
|
||||
});
|
||||
expect(this.app.get('baz')).to.eql(true);
|
||||
});
|
||||
|
||||
describe('PaaS and npm env variables', function() {
|
||||
beforeEach(function() {
|
||||
this.boot = function () {
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
*/
|
||||
|
||||
assert = require('assert');
|
||||
expect = require('chai').expect;
|
||||
loopback = require('../');
|
||||
memoryConnector = loopback.Memory;
|
||||
GeoPoint = loopback.GeoPoint;
|
||||
|
|
Loading…
Reference in New Issue