Added initial test for removing challenge checklist item

This commit is contained in:
Keith Holliday
2016-03-12 10:55:12 -06:00
parent c02082a200
commit 152f7605cd
2 changed files with 116 additions and 1 deletions

View File

@@ -703,7 +703,7 @@ api.removeChecklistItem = {
if (!task) {
throw new NotFound(res.t('taskNotFound'));
} else if (!task.userId) { // If the task belongs to a challenge make sure the user has rights
challenge = await Challenge.find().selec({_id: task.challenge.id}).select('leader').exec();
challenge = await Challenge.findOne({_id: task.challenge.id}).exec();
if (!challenge) throw new NotFound(res.t('challengeNotFound'));
if (challenge.leader !== user._id) throw new NotAuthorized(res.t('onlyChalLeaderEditTasks'));
} else if (task.userId !== user._id) { // If the task is owned by an user make it's the current one