aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkumar <kumar.damani@mail.utoronto.ca>2016-07-27 18:04:42 +0000
committerkumar <kumar.damani@mail.utoronto.ca>2016-07-27 18:04:42 +0000
commit11854aac96d07d7f1f428df693d349b0c38750eb (patch)
tree2dfbdf7dcc1be2b20589dd26914eb77ecbb1c536
parentdd90e9fbeef08b3f25c21e3e3725ce6b7d14ff7a (diff)
parent807b2b72e6b83339ecb4f5f23999ce8d22d9db46 (diff)
pull
Merge branch 'master' of https://github.com/HumairAK/solutions_repo
-rw-r--r--app.js9
-rw-r--r--dbTests/exams_data.json (renamed from test/dbTests/exams_data.json)0
-rw-r--r--dbTests/resulst.txt (renamed from test/dbTests/resulst.txt)0
-rw-r--r--dbTests/test_main.js (renamed from test/dbTests/test_main.js)0
-rw-r--r--dbTests/testingDocs.txt (renamed from test/dbTests/testingDocs.txt)0
-rw-r--r--dbTests/users_data.json (renamed from test/dbTests/users_data.json)0
-rw-r--r--node_simple.js10
-rw-r--r--routes/user.js6
-rw-r--r--test/routingDb_tests.js22
-rw-r--r--test/test_server.js2
10 files changed, 28 insertions, 21 deletions
diff --git a/app.js b/app.js
index b0008a3..1bf49f7 100644
--- a/app.js
+++ b/app.js
@@ -73,7 +73,7 @@ app.use('/', routes);
/* Handle error page */
app.use(function(req, res, next){
- res.status(404 || 500);
+ res.status(404);
// respond with html page
if (req.accepts('html')) {
@@ -86,5 +86,12 @@ app.use(function(req, res, next){
});
+app.use(function(error, req, res, next) {
+ res.status(500);
+ url = req.url;
+ res.render('error', {error: error, url: url});
+});
+
+
module.exports = app;
diff --git a/test/dbTests/exams_data.json b/dbTests/exams_data.json
index 493bbf5..493bbf5 100644
--- a/test/dbTests/exams_data.json
+++ b/dbTests/exams_data.json
diff --git a/test/dbTests/resulst.txt b/dbTests/resulst.txt
index e66b964..e66b964 100644
--- a/test/dbTests/resulst.txt
+++ b/dbTests/resulst.txt
diff --git a/test/dbTests/test_main.js b/dbTests/test_main.js
index fcdf74b..fcdf74b 100644
--- a/test/dbTests/test_main.js
+++ b/dbTests/test_main.js
diff --git a/test/dbTests/testingDocs.txt b/dbTests/testingDocs.txt
index cb1290b..cb1290b 100644
--- a/test/dbTests/testingDocs.txt
+++ b/dbTests/testingDocs.txt
diff --git a/test/dbTests/users_data.json b/dbTests/users_data.json
index f10877c..f10877c 100644
--- a/test/dbTests/users_data.json
+++ b/dbTests/users_data.json
diff --git a/node_simple.js b/node_simple.js
index 1692527..c787bb0 100644
--- a/node_simple.js
+++ b/node_simple.js
@@ -422,9 +422,6 @@ exports.add_user = function (fields, callbackUser) {
});
};
-
-
-
/**
* This function returns whether the user with the given username has already been signed in before.
* This is important because we need to link a unique facebook account with a username. If the user has signed in
@@ -450,7 +447,6 @@ exports.userVerifiedBefore = function(username, callback) {
});
};
-
/**
* THis function adds the user's facebook account verification to the database and links it to the user's local in site
* account.
@@ -599,7 +595,6 @@ exports.findUserByID = function (id, callback) {
/************************* COURSES / EXAMS **********************************/
-
/**
* Remvove a course from ONLY the courses table IN CASE of accidental
* addition.
@@ -634,7 +629,6 @@ exports.remove_course = function (course_code, callback) {
});
};
-
/**
* This function will add the given exam_id to the given user's followers list.
* It simply appends the exam_id to the list and nothing else.
@@ -684,10 +678,6 @@ exports.followExam = function (user_name, exam_id, callback) {
});
};
-
-
-
-
/**
* This function returns an array where each element contains info for a particular question
* such as the question number (_id), number of solutions (count), and number of comments
diff --git a/routes/user.js b/routes/user.js
index 2b8453f..7c88ed4 100644
--- a/routes/user.js
+++ b/routes/user.js
@@ -158,7 +158,6 @@ router.get('/signin', loggedOut, function (req, res, next) {
});
});
-
/** Render/GET verification page. */
router.get('/verify', function(req, res, next) {
if (req.user.email) {
@@ -169,7 +168,6 @@ router.get('/verify', function(req, res, next) {
});
-
/** Retrieves infomation from the signup form, form validates and sends it to passport.js to authenticate. */
router.post('/signup', loggedOut, function(req, res, next) {
req.assert('fname', 'Please enter a valid first name.').notEmpty().withMessage('First name required.').isAlpha();
@@ -387,7 +385,6 @@ router.post('/solution/vote/:examID/:qID/:solID', function(req, res, next){
});
-
/**
* Retrieves information about the exam following button, redirects if there is an error, and shows an error alert
* if the user is not logged in.
@@ -416,9 +413,6 @@ router.post('/follow_exam/:examID',function (req, res) {
}
});
-
-
-
module.exports = router;
/************** Route protection ********************/
diff --git a/test/routingDb_tests.js b/test/routingDb_tests.js
index d3a607f..b700f4c 100644
--- a/test/routingDb_tests.js
+++ b/test/routingDb_tests.js
@@ -1,5 +1,6 @@
var chai = require('chai');
var chaiHttp = require('chai-http');
+var dbFile = require('../node_simple');
var expect = require('chai').expect;
var assert = chai.assert;
var url = require("url");
@@ -41,6 +42,18 @@ var users = (JSON.parse(usersPull));
chai.use(chaiHttp);
+
+
+/* Set up DB connection as it is required for the test cases below*/
+dbFile.setupDB(function (success, mssg) {
+ if(success){
+ console.log('Db Connection success');
+ } else{
+ console.log('Failed to connect');
+ }
+});
+
+
/* Test simple routes that do not require database queries */
describe('Test Basic Route:', function () {
@@ -112,9 +125,11 @@ describe('Test Basic Route:', function () {
/* Public profile page response test */
describe('User profile page (public) Route:', function(){
var server;
- before(function () {
+ before(function (done) {
server = require('./test_server');
+ done();
});
+
after(function () {
server.close();
});
@@ -125,7 +140,6 @@ describe('User profile page (public) Route:', function(){
.get('/public_profile/' + username)
.end(function(err, res){
expect(res).to.have.status(200);
-
var path = res.res.req.path;
assert.equal(path, '/public_profile/' + username); // Check url path
done();
@@ -293,11 +307,11 @@ describe('Questions Search Route:', function(){
chai.request(server)
.get('/questions/batman')
.end(function(err, res){
- expect(res).to.have.status(200);
+ expect(res).to.have.status(500);
var path = res.res.req.path;
// Redirected to homepage (with err msg)
- assert.equal(path, '/');
+ assert.equal(path, '/questions/batman');
done();
});
});
diff --git a/test/test_server.js b/test/test_server.js
index 9514124..a492f2d 100644
--- a/test/test_server.js
+++ b/test/test_server.js
@@ -10,4 +10,6 @@ server.listen(port, function(){
console.log('Listening on port 3000..');
});
+
+
module.exports = server; \ No newline at end of file