fix: allows user to save an alias and checklistCollapsed properties of a challenge task. fixes #7875 (#8170)

This commit is contained in:
Travis
2016-10-25 19:47:49 -07:00
committed by Blade Barringer
parent d4e20ee4aa
commit 0bfc9d9516
2 changed files with 5 additions and 1 deletions

View File

@@ -74,6 +74,7 @@ describe('PUT /tasks/:id', () => {
checklist: [ checklist: [
{text: 123, completed: false}, {text: 123, completed: false},
], ],
collapseChecklist: false,
}); });
await sleep(2); await sleep(2);
@@ -111,6 +112,7 @@ describe('PUT /tasks/:id', () => {
{text: 123, completed: false}, {text: 123, completed: false},
{text: 456, completed: true}, {text: 456, completed: true},
], ],
collapseChecklist: true,
notes: 'new notes', notes: 'new notes',
attribute: 'per', attribute: 'per',
tags: [challengeUserTaskId], tags: [challengeUserTaskId],
@@ -143,6 +145,8 @@ describe('PUT /tasks/:id', () => {
expect(savedChallengeUserTask.streak).to.equal(25); expect(savedChallengeUserTask.streak).to.equal(25);
expect(savedChallengeUserTask.reminders.length).to.equal(2); expect(savedChallengeUserTask.reminders.length).to.equal(2);
expect(savedChallengeUserTask.checklist.length).to.equal(2); expect(savedChallengeUserTask.checklist.length).to.equal(2);
expect(savedChallengeUserTask.alias).to.equal('a-short-task-name');
expect(savedChallengeUserTask.collapseChecklist).to.equal(true);
}); });
}); });

View File

@@ -119,7 +119,7 @@ TaskSchema.statics.findByIdOrAlias = async function findByIdOrAlias (identifier,
TaskSchema.statics.sanitizeUserChallengeTask = function sanitizeUserChallengeTask (taskObj) { TaskSchema.statics.sanitizeUserChallengeTask = function sanitizeUserChallengeTask (taskObj) {
let initialSanitization = this.sanitize(taskObj); let initialSanitization = this.sanitize(taskObj);
return _.pick(initialSanitization, ['streak', 'checklist', 'attribute', 'reminders', 'tags', 'notes']); return _.pick(initialSanitization, ['streak', 'checklist', 'attribute', 'reminders', 'tags', 'notes', 'collapseChecklist', 'alias']);
}; };
// Sanitize checklist objects (disallowing id) // Sanitize checklist objects (disallowing id)