add clearCompletedTodos route with tests, add test for getting completed todos, misc fixes

This commit is contained in:
Matteo Pagliazzi
2016-01-25 17:23:01 +01:00
parent 4149cbf381
commit d5751837ed
5 changed files with 51 additions and 7 deletions

View File

@@ -48,13 +48,13 @@ TaskSchema.plugin(baseModel, {
// A list of additional fields that cannot be set on creation (but can be set on updare)
let noCreate = ['completed']; // TODO completed should be removed for updates too?
TaskSchema.statics.sanitizeCreate = function sanitizeCreate (createObj) {
return Task.sanitize(createObj, noCreate); // eslint-disable-line no-use-before-define
return this.sanitize(createObj, noCreate);
};
// A list of additional fields that cannot be updated (but can be set on creation)
let noUpdate = ['_id', 'type'];
TaskSchema.statics.sanitizeUpdate = function sanitizeUpdate (updateObj) {
return Task.sanitize(updateObj, noUpdate); // eslint-disable-line no-use-before-define
return this.sanitize(updateObj, noUpdate);
};
// Sanitize checklist objects (disallowing _id)