Fix: reset streak for habits after rebirth (#11345)

* Fix: reset streak for habits after rebirth

- Modify current test of reseting streaks
- Add new if branch for task with "habit" type

* Fix: reset habits by another keys (counterDown/counterUp):

- Fix test for correct way of reseting habits
- Use another keys for reseting habits
This commit is contained in:
Aleksey
2019-09-09 16:46:49 +03:00
committed by Matteo Pagliazzi
parent 7219aa963b
commit 65906f0b71
2 changed files with 8 additions and 0 deletions

View File

@@ -86,10 +86,14 @@ describe('shared.ops.rebirth', () => {
});
it('resets user\'s daily streaks to 0', () => {
tasks[0].counterDown = 1; // Habit
tasks[0].counterUp = 1; // Habit
tasks[1].streak = 1; // Daily
rebirth(user, tasks);
expect(tasks[0].counterDown).to.equal(0);
expect(tasks[0].counterUp).to.equal(0);
expect(tasks[1].streak).to.equal(0);
});

View File

@@ -47,6 +47,10 @@ module.exports = function rebirth (user, tasks = [], req = {}, analytics) {
if (task.type === 'daily') {
task.streak = 0;
}
if (task.type === 'habit') {
task.counterDown = 0;
task.counterUp = 0;
}
}
});