mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 23:27:26 +01:00
Fixed update query to revert challenge tags when broken (#9791)
This commit is contained in:
@@ -149,13 +149,19 @@ describe('POST /challenges/:challengeId/winner/:winnerId', () => {
|
|||||||
|
|
||||||
await sleep(0.5);
|
await sleep(0.5);
|
||||||
|
|
||||||
let tasks = await winningUser.get('/tasks/user');
|
const tasks = await winningUser.get('/tasks/user');
|
||||||
let testTask = _.find(tasks, (task) => {
|
const testTask = _.find(tasks, (task) => {
|
||||||
return task.text === taskText;
|
return task.text === taskText;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const updatedUser = await winningUser.sync();
|
||||||
|
const challengeTag = updatedUser.tags.find(tags => {
|
||||||
|
return tags.id === challenge._id;
|
||||||
|
});
|
||||||
|
|
||||||
expect(testTask.challenge.broken).to.eql('CHALLENGE_CLOSED');
|
expect(testTask.challenge.broken).to.eql('CHALLENGE_CLOSED');
|
||||||
expect(testTask.challenge.winner).to.eql(winningUser.profile.name);
|
expect(testTask.challenge.winner).to.eql(winningUser.profile.name);
|
||||||
|
expect(challengeTag.challenge).to.eql('false');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -341,7 +341,7 @@ schema.methods.closeChal = async function closeChal (broken = {}) {
|
|||||||
// Set the challenge tag to non-challenge status and remove the challenge from the user's challenges
|
// Set the challenge tag to non-challenge status and remove the challenge from the user's challenges
|
||||||
User.update({
|
User.update({
|
||||||
challenges: challenge._id,
|
challenges: challenge._id,
|
||||||
'tags._id': challenge._id,
|
'tags.id': challenge._id,
|
||||||
}, {
|
}, {
|
||||||
$set: {'tags.$.challenge': false},
|
$set: {'tags.$.challenge': false},
|
||||||
$pull: {challenges: challenge._id},
|
$pull: {challenges: challenge._id},
|
||||||
|
|||||||
Reference in New Issue
Block a user