From e33fdf24432b4bba5467cdaf51f2e84d8dfa493c Mon Sep 17 00:00:00 2001 From: David Baldwynn Date: Thu, 28 Apr 2016 23:22:47 -0700 Subject: [PATCH] fixed server tests --- app/controllers/forms.server.controller.js | 2 +- app/models/form.server.model.js | 18 +++++++++--------- app/tests/form_submission.model.test.js | 20 ++++++++++---------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/app/controllers/forms.server.controller.js b/app/controllers/forms.server.controller.js index af5936e6..1f1ca113 100644 --- a/app/controllers/forms.server.controller.js +++ b/app/controllers/forms.server.controller.js @@ -303,7 +303,7 @@ exports.formByID = function(req, res, next, id) { else { Form.findById(id).populate('admin').exec(function(err, form) { if (err) { - return return next(err); + return next(err); } else if (form === undefined || form === null) { res.status(400).send({ message: 'Form not found' diff --git a/app/models/form.server.model.js b/app/models/form.server.model.js index 02ff64f4..4fd607ad 100644 --- a/app/models/form.server.model.js +++ b/app/models/form.server.model.js @@ -241,7 +241,7 @@ function getDeletedIndexes(needle, haystack){ FormSchema.pre('save', function (next) { var that = this; - async.series([function(return cb) { + async.series([function(cb) { that.constructor .findOne({_id: that._id}).exec(function (err, original) { if (err) { @@ -254,7 +254,7 @@ FormSchema.pre('save', function (next) { return cb(null); } }); - }, function(return cb) { + }, function(cb) { //DAVID: TODO: Make this so we don't have to update the validFields property ever save if (that.plugins.oscarhost.hasOwnProperty('baseUrl')) { var validUpdateTypes = mongoose.model('Form').schema.path('plugins.oscarhost.settings.updateType').enumValues; @@ -262,10 +262,10 @@ FormSchema.pre('save', function (next) { } return cb(null); }, - function(return cb) { + function(cb) { if (that.pdf) { async.series([ - function (return callback) { + function (callback) { if (that.isModified('pdf') && that.pdf.path) { var new_filename = that.title.replace(/ /g, '') + '_template.pdf'; @@ -279,7 +279,7 @@ FormSchema.pre('save', function (next) { mkdirp.sync(newDestination); } if (stat && !stat.isDirectory()) { - return return callback(new Error('Directory cannot be created because an inode of a different type exists at "' + config.pdfUploadPath + '"'), null); + return callback(new Error('Directory cannot be created because an inode of a different type exists at "' + config.pdfUploadPath + '"'), null); } var old_path = that.pdf.path; @@ -298,7 +298,7 @@ FormSchema.pre('save', function (next) { return callback(null, 'task1'); } }, - function (return callback) { + function (callback) { if (that.isGenerated) { that.pdf.path = config.pdfUploadPath + that.admin.username.replace(/ /g, '') + '/' + that.title.replace(/ /g, '') + '/' + that.title.replace(/ /g, '') + '_template.pdf'; that.pdf.name = that.title.replace(/ /g, '') + '_template.pdf'; @@ -376,7 +376,7 @@ FormSchema.pre('save', function (next) { } else return cb(); }, - function(return cb) { + function(cb) { if(that.isModified('form_fields') && that.form_fields && _original){ @@ -391,7 +391,7 @@ FormSchema.pre('save', function (next) { var modifiedSubmissions = []; async.forEachOfSeries(deletedIds, - function (deletedIdIndex, key, return cb_id) { + function (deletedIdIndex, key, cb_id) { var deleted_id = old_ids[deletedIdIndex]; @@ -420,7 +420,7 @@ FormSchema.pre('save', function (next) { } else { //Iterate through all submissions with modified form_fields - async.forEachOfSeries(modifiedSubmissions, function (submission, key, return callback) { + async.forEachOfSeries(modifiedSubmissions, function (submission, key, callback) { //Iterate through ids of deleted fields for (var i = 0; i < deletedIds.length; i++) { diff --git a/app/tests/form_submission.model.test.js b/app/tests/form_submission.model.test.js index ab1b1bae..5a048919 100644 --- a/app/tests/form_submission.model.test.js +++ b/app/tests/form_submission.model.test.js @@ -107,16 +107,16 @@ describe('FormSubmission Model Unit Tests:', function() { {'fieldType':'radio', 'title':'And your sex', 'fieldOptions': [{ 'option_id': 0, 'option_title': 'Male', 'option_value': 'M' }, { 'option_id': 1, 'option_title': 'Female', 'option_value': 'F' }], 'fieldValue': ''}, {'fieldType':'date', 'title':'When were you born?', 'fieldValue': ''}, {'fieldType':'number', 'title':'What\'s your phone #?', 'fieldValue': ''} - ], - plugins: { - oscarhost: { - baseUrl: config.oscarhost.baseUrl, - settings: { - updateType: 'force_add' - }, - auth: config.oscarhost.auth - } - } + ] + // plugins: { + // oscarhost: { + // baseUrl: config.oscarhost.baseUrl, + // settings: { + // updateType: 'force_add' + // }, + // auth: config.oscarhost.auth + // } + // } }); myForm.save(function(err, form){