Ensured group tasks are removed from places that challegnes tasks are (#8359)

* Ensured group tasks are removed from places that challegnes tasks are

* Added tests for user reset and class cast
This commit is contained in:
Keith Holliday
2017-01-07 05:01:12 -06:00
committed by Matteo Pagliazzi
parent 28e8ec2d2c
commit 857aa5827b
7 changed files with 72 additions and 9 deletions

View File

@@ -917,6 +917,8 @@ api.clearCompletedTodos = {
$or: [
{'challenge.id': {$exists: false}},
{'challenge.broken': {$exists: true}},
{'group.id': {$exists: false}},
{'group.broken': {$exists: true}},
],
}).exec();

View File

@@ -372,6 +372,7 @@ api.castSpell = {
}).exec();
if (!task) throw new NotFound(res.t('taskNotFound'));
if (task.challenge.id) throw new BadRequest(res.t('challengeTasksNoCast'));
if (task.group.id) throw new BadRequest(res.t('groupTasksNoCast'));
spell.cast(user, task, req);
@@ -394,6 +395,8 @@ api.castSpell = {
$or: [ // exclude challenge tasks
{'challenge.id': {$exists: false}},
{'challenge.broken': {$exists: true}},
{'group.id': {$exists: false}},
{'group.broken': {$exists: true}},
],
}).exec();
@@ -1055,6 +1058,8 @@ api.userRebirth = {
$or: [ // exclude challenge tasks
{'challenge.id': {$exists: false}},
{'challenge.broken': {$exists: true}},
{'group.id': {$exists: false}},
{'group.broken': {$exists: true}},
],
}).exec();
@@ -1171,6 +1176,8 @@ api.userReroll = {
$or: [ // exclude challenge tasks
{'challenge.id': {$exists: false}},
{'challenge.broken': {$exists: true}},
{'group.id': {$exists: false}},
{'group.broken': {$exists: true}},
],
};
let tasks = await Tasks.Task.find(query).exec();
@@ -1206,8 +1213,10 @@ api.userReset = {
$or: [ // exclude challenge tasks
{'challenge.id': {$exists: false}},
{'challenge.broken': {$exists: true}},
{'group.id': {$exists: false}},
{'group.broken': {$exists: true}},
],
}).select('_id type challenge').exec();
}).select('_id type challenge group').exec();
let resetRes = common.ops.reset(user, tasks);