bring in basic controller testing. NOTE: changes solve Mongo Session issue,
Error: Error setting TTL index on collection : sessions at /Users/weston/git/hackathon-starter/node_modules/connect-mongo/lib/connect-mongo.js:161:23 at /Users/weston/git/hackathon-starter/node_modules/mongoose/node_modules/mongodb/lib/mongodb/db.js:1404:28 at /Users/weston/git/hackathon-starter/node_modules/mongoose/node_modules/mongodb/lib/mongodb/db.js:1542:30 at /Users/weston/git/hackathon-starter/node_modules/mongoose/node_modules/mongodb/lib/mongodb/cursor.js:159:22 at commandHandler (/Users/weston/git/hackathon-starter/node_modules/mongoose/node_modules/mongodb/lib/mongodb/cursor.js:678:48) at /Users/weston/git/hackathon-starter/node_modules/mongoose/node_modules/mongodb/lib/mongodb/db.js:1806:9
This commit is contained in:
5
app.js
5
app.js
@@ -34,12 +34,13 @@ var passportConf = require('./config/passport');
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
var app = express();
|
var app = express();
|
||||||
|
module.exports = app;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mongoose configuration.
|
* Mongoose configuration.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mongoose.connect(secrets.db);
|
mongoose.connect(secrets.url);
|
||||||
mongoose.connection.on('error', function() {
|
mongoose.connection.on('error', function() {
|
||||||
console.error('✗ MongoDB Connection Error. Please make sure MongoDB is running.');
|
console.error('✗ MongoDB Connection Error. Please make sure MongoDB is running.');
|
||||||
});
|
});
|
||||||
@@ -71,7 +72,7 @@ app.use(express.methodOverride());
|
|||||||
app.use(express.session({
|
app.use(express.session({
|
||||||
secret: secrets.sessionSecret,
|
secret: secrets.sessionSecret,
|
||||||
store: new MongoStore({
|
store: new MongoStore({
|
||||||
db: mongoose.connection.db,
|
url: secrets.url,
|
||||||
auto_reconnect: true
|
auto_reconnect: true
|
||||||
})
|
})
|
||||||
}));
|
}));
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
"name": "hackathon-starter",
|
"name": "hackathon-starter",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node app.js",
|
"start": "node app.js",
|
||||||
"test": "mocha tests/**/*.js"
|
"test": "mocha tests/**/*.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -42,6 +42,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"chai": "~1.9.0",
|
"chai": "~1.9.0",
|
||||||
"mocha": "~1.17.1"
|
"mocha": "~1.17.1",
|
||||||
|
"supertest": "~0.9.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
16
tests/controllers/user_specs.js
Normal file
16
tests/controllers/user_specs.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
process.env.NODE_ENV = 'test';
|
||||||
|
|
||||||
|
var request = require('supertest')
|
||||||
|
, express = require('express')
|
||||||
|
, mocha = require('mocha')
|
||||||
|
, app = require('../../app.js');
|
||||||
|
|
||||||
|
describe('GET /', function(){
|
||||||
|
it('should return HTTP 200', function(done){
|
||||||
|
request(app)
|
||||||
|
.get('/')
|
||||||
|
.expect(200, done);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user