diff --git a/middlewares/hacker.middleware.js b/middlewares/hacker.middleware.js index 69759041..8d8369a8 100644 --- a/middlewares/hacker.middleware.js +++ b/middlewares/hacker.middleware.js @@ -31,12 +31,12 @@ function parsePatch(req, res, next) { /** * @function parseHacker - * @param {{body: {accountId: ObjectId, school: string, gender: string, needsBus: string, application: Object, authorization: string}}} req + * @param {{body: {accountId: ObjectId, school: string, degree: string, gender: string, needsBus: string, application: Object, authorization: string}}} req * @param {*} res * @param {(err?)=>void} next * @return {void} * @description - * Moves accountId, school, gender, needsBus, application from req.body to req.body.hackerDetails. + * Moves accountId, school, degree, gender, needsBus, application from req.body to req.body.hackerDetails. * Adds _id to hackerDetails. */ function parseHacker(req, res, next) { @@ -44,6 +44,7 @@ function parseHacker(req, res, next) { _id: mongoose.Types.ObjectId(), accountId: req.body.accountId, school: req.body.school, + degree: req.body.degree, gender: req.body.gender, needsBus: req.body.needsBus, application: req.body.application, @@ -57,6 +58,7 @@ function parseHacker(req, res, next) { delete req.body.accountId; delete req.body.school; + delete req.body.degree; delete req.body.gender; delete req.body.needsBus; delete req.body.application; diff --git a/middlewares/validators/hacker.validator.js b/middlewares/validators/hacker.validator.js index e8e9f677..cbe2b984 100644 --- a/middlewares/validators/hacker.validator.js +++ b/middlewares/validators/hacker.validator.js @@ -6,6 +6,7 @@ module.exports = { // status will be added automatically VALIDATOR.mongoIdValidator("body", "accountId", false), VALIDATOR.nameValidator("body", "school", false), + VALIDATOR.nameValidator("body", "degree", false), VALIDATOR.nameValidator("body", "gender", false), VALIDATOR.booleanValidator("body", "needsBus", false), VALIDATOR.applicationValidator("body", "application", false), @@ -22,6 +23,7 @@ module.exports = { // untested updateHackerValidator: [ VALIDATOR.nameValidator("body", "school", true), + VALIDATOR.nameValidator("body", "degree", true), VALIDATOR.nameValidator("body", "gender", true), VALIDATOR.applicationValidator("body", "application", true), VALIDATOR.booleanValidator("body", "needsBus", true) diff --git a/models/hacker.model.js b/models/hacker.model.js index 64d2b359..1cd632b1 100644 --- a/models/hacker.model.js +++ b/models/hacker.model.js @@ -20,6 +20,10 @@ const HackerSchema = new mongoose.Schema({ type: String, required: true }, + degree: { + type: String, + required: true + }, //no enum for this gender: { type: String diff --git a/tests/util/hacker.test.util.js b/tests/util/hacker.test.util.js index 75d6e4d6..8f32ff44 100644 --- a/tests/util/hacker.test.util.js +++ b/tests/util/hacker.test.util.js @@ -12,6 +12,7 @@ const invalidHacker1 = { // invalid mongoID "accountId": "UtilAccountAccount1_id", // invalid missing school attribute + "degree": "Undersaduate", "gender": "Female", "needsBus": true, "application": { @@ -31,6 +32,7 @@ const duplicateAccountLinkHacker1 = { "accountId": Util.Account.Account1._id, "status": "Applied", "school": "University of Blah", + "degree": "Undergraduate", "gender": "Male", "needsBus": true, "application": { @@ -55,6 +57,7 @@ const duplicateAccountLinkHacker1 = { const newHacker1 = { "accountId": Util.Account.generatedAccounts[6]._id, "school": "University of ASDF", + "degree": "Masters", "gender": "Female", "needsBus": true, "application": { @@ -79,6 +82,7 @@ const newHacker1 = { const newHacker2 = { "accountId": Util.Account.NonConfirmedAccount1._id, "school": "University of YIKES", + "degree": "PhD", "gender": "Female", "needsBus": true, "application": { @@ -105,6 +109,7 @@ const HackerA = { "accountId": Util.Account.Account1._id, "status": "Confirmed", "school": "University of Blah", + "degree": "Masters", "gender": "Male", "needsBus": true, "application": { @@ -130,6 +135,7 @@ const HackerB = { "accountId": Util.Account.Account2._id, "status": "Accepted", "school": "University of Blah1", + "degree": "Masters", "gender": "Female", "needsBus": false, "application": { @@ -156,6 +162,7 @@ const HackerC = { "accountId": Util.Account.Hacker3._id, "status": "Waitlisted", "school": "University of Blah1", + "degree": "Masters", "gender": "Female", "needsBus": false, "application": {