mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 06:07:21 +01:00
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:
committed by
Matteo Pagliazzi
parent
7219aa963b
commit
65906f0b71
@@ -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);
|
||||
});
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user