mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 07:07:35 +01:00
fix failing tests
This commit is contained in:
@@ -79,7 +79,7 @@ describe('PUT /tasks/:id', () => {
|
|||||||
let id2 = generateUUID();
|
let id2 = generateUUID();
|
||||||
|
|
||||||
let savedDaily = await user.put(`/tasks/${daily._id}`, {
|
let savedDaily = await user.put(`/tasks/${daily._id}`, {
|
||||||
checklist: [
|
reminders: [
|
||||||
{id: id1, time: new Date(), startDate: new Date()},
|
{id: id1, time: new Date(), startDate: new Date()},
|
||||||
{id: id2, time: new Date(), startDate: new Date()},
|
{id: id2, time: new Date(), startDate: new Date()},
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ describe('PUT /tasks/:taskId/checklist/:itemId', () => {
|
|||||||
savedTask = await user.put(`/tasks/${task._id}/checklist/${savedTask.checklist[0]._id}`, {
|
savedTask = await user.put(`/tasks/${task._id}/checklist/${savedTask.checklist[0]._id}`, {
|
||||||
text: 'updated',
|
text: 'updated',
|
||||||
completed: true,
|
completed: true,
|
||||||
_id: 123,
|
_id: 123, // ignored
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(savedTask.checklist.length).to.equal(1);
|
expect(savedTask.checklist.length).to.equal(1);
|
||||||
|
|||||||
@@ -570,7 +570,7 @@ api.addChecklistItem = {
|
|||||||
|
|
||||||
if (task.type !== 'daily' && task.type !== 'todo') throw new BadRequest(res.t('checklistOnlyDailyTodo'));
|
if (task.type !== 'daily' && task.type !== 'todo') throw new BadRequest(res.t('checklistOnlyDailyTodo'));
|
||||||
|
|
||||||
task.checklist.push(Tasks.Task.sanitizeChecklist(req.body));
|
task.checklist.push(Tasks.Task.sanitizeChecklist(req.body)); // TODO why not allow to supply _id on creation?
|
||||||
let savedTask = await task.save();
|
let savedTask = await task.save();
|
||||||
|
|
||||||
res.respond(200, savedTask); // TODO what to return
|
res.respond(200, savedTask); // TODO what to return
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ TaskSchema.statics.sanitizeChecklist = function sanitizeChecklist (checklistObj)
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Sanitize reminder objects (disallowing id)
|
// Sanitize reminder objects (disallowing id)
|
||||||
TaskSchema.statics.sanitizeChecklist = function sanitizeChecklist (reminderObj) {
|
TaskSchema.statics.sanitizeReminder = function sanitizeReminder (reminderObj) {
|
||||||
delete reminderObj.id;
|
delete reminderObj.id;
|
||||||
return reminderObj;
|
return reminderObj;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user