mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
Fixed issue when repeat object is malformed (#8765)
* Fixed issue when repeat object is malformed * Removed only * Changed numeric check to lodash isFinite * Removed newer lodash function
This commit is contained in:
committed by
Sabe Jones
parent
feae40cf0a
commit
6f034bb5dd
@@ -322,6 +322,25 @@ describe('shouldDo', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('returns false and ignore malformed repeat object', () => {
|
||||||
|
dailyTask.repeat = {
|
||||||
|
su: false,
|
||||||
|
s: false,
|
||||||
|
f: false,
|
||||||
|
th: false,
|
||||||
|
w: false,
|
||||||
|
t: false,
|
||||||
|
m: false,
|
||||||
|
errors: 'errors',
|
||||||
|
};
|
||||||
|
|
||||||
|
for (let weekday of [0, 1, 2, 3, 4, 5, 6]) {
|
||||||
|
day = moment().day(weekday).toDate();
|
||||||
|
|
||||||
|
expect(shouldDo(day, dailyTask, options)).to.equal(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
it('returns false if day of the week does not match and active on the day it matches', () => {
|
it('returns false if day of the week does not match and active on the day it matches', () => {
|
||||||
dailyTask.repeat = {
|
dailyTask.repeat = {
|
||||||
su: false,
|
su: false,
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ export function shouldDo (day, dailyTask, options = {}) {
|
|||||||
|
|
||||||
if (dailyTask.repeat) {
|
if (dailyTask.repeat) {
|
||||||
for (let [repeatDay, active] of Object.entries(dailyTask.repeat)) {
|
for (let [repeatDay, active] of Object.entries(dailyTask.repeat)) {
|
||||||
|
if (!isFinite(DAY_MAPPING_STRING_TO_NUMBER[repeatDay])) continue; // eslint-disable-line no-continue
|
||||||
if (active) daysOfTheWeek.push(parseInt(DAY_MAPPING_STRING_TO_NUMBER[repeatDay], 10));
|
if (active) daysOfTheWeek.push(parseInt(DAY_MAPPING_STRING_TO_NUMBER[repeatDay], 10));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user