diff --git a/lib/application.js b/lib/application.js index 73c09726..d63e292d 100644 --- a/lib/application.js +++ b/lib/application.js @@ -252,6 +252,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); diff --git a/package.json b/package.json index f6853850..60daf80f 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test/app.test.js b/test/app.test.js index 3787503a..46ff2576 100644 --- a/test/app.test.js +++ b/test/app.test.js @@ -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 () { diff --git a/test/support.js b/test/support.js index 15999e40..2262e294 100644 --- a/test/support.js +++ b/test/support.js @@ -3,6 +3,7 @@ */ assert = require('assert'); +expect = require('chai').expect; loopback = require('../'); memoryConnector = loopback.Memory; GeoPoint = loopback.GeoPoint;