mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 07:37:25 +01:00
Corrected reset checklist logic (#7154)
* Corrected reset checklist logic * Change cron logic to reset rather than set * Remove extra paranthesis
This commit is contained in:
committed by
Matteo Pagliazzi
parent
e19130bd8c
commit
20f9bbf449
@@ -298,19 +298,19 @@ describe('cron', () => {
|
|||||||
expect(tasksByType.dailys[0].completed).to.be.false;
|
expect(tasksByType.dailys[0].completed).to.be.false;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set task checklist to completed for completed dailys', () => {
|
it('should reset task checklist for completed dailys', () => {
|
||||||
tasksByType.dailys[0].checklist.push({title: 'test', completed: false});
|
tasksByType.dailys[0].checklist.push({title: 'test', completed: false});
|
||||||
tasksByType.dailys[0].completed = true;
|
tasksByType.dailys[0].completed = true;
|
||||||
cron({user, tasksByType, daysMissed, analytics});
|
cron({user, tasksByType, daysMissed, analytics});
|
||||||
expect(tasksByType.dailys[0].checklist[0].completed).to.be.true;
|
expect(tasksByType.dailys[0].checklist[0].completed).to.be.false;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set task checklist to completed for dailys with scheduled misses', () => {
|
it('should reset task checklist for dailys with scheduled misses', () => {
|
||||||
daysMissed = 10;
|
daysMissed = 10;
|
||||||
tasksByType.dailys[0].checklist.push({title: 'test', completed: false});
|
tasksByType.dailys[0].checklist.push({title: 'test', completed: false});
|
||||||
tasksByType.dailys[0].startDate = moment(new Date()).subtract({days: 1});
|
tasksByType.dailys[0].startDate = moment(new Date()).subtract({days: 1});
|
||||||
cron({user, tasksByType, daysMissed, analytics});
|
cron({user, tasksByType, daysMissed, analytics});
|
||||||
expect(tasksByType.dailys[0].checklist[0].completed).to.be.true;
|
expect(tasksByType.dailys[0].checklist[0].completed).to.be.false;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should do damage for missing a daily', () => {
|
it('should do damage for missing a daily', () => {
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ export function cron (options = {}) {
|
|||||||
task.completed = false;
|
task.completed = false;
|
||||||
|
|
||||||
if (completed || scheduleMisses > 0) {
|
if (completed || scheduleMisses > 0) {
|
||||||
task.checklist.forEach(i => i.completed = true); // FIXME this should not happen for grey tasks unless they are completed
|
task.checklist.forEach(i => i.completed = false); // FIXME this should not happen for grey tasks unless they are completed
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user