mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
Fix challenge update (#11148)
* Fix challenge update Fix some problem in challenge update * Fix test * Move leader to noUpdate * Move leader to noUpdate
This commit is contained in:
committed by
Matteo Pagliazzi
parent
d8ea3bd23a
commit
c0837e3b3c
@@ -56,11 +56,11 @@ describe('PUT /challenges/:challengeId', () => {
|
|||||||
tasksOrder: 'new order',
|
tasksOrder: 'new order',
|
||||||
official: true,
|
official: true,
|
||||||
shortName: 'new short name',
|
shortName: 'new short name',
|
||||||
|
leader: member._id,
|
||||||
|
|
||||||
// applied
|
// applied
|
||||||
name: 'New Challenge Name',
|
name: 'New Challenge Name',
|
||||||
description: 'New challenge description.',
|
description: 'New challenge description.',
|
||||||
leader: member._id,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(res.prize).to.equal(0);
|
expect(res.prize).to.equal(0);
|
||||||
@@ -76,12 +76,12 @@ describe('PUT /challenges/:challengeId', () => {
|
|||||||
expect(res.shortName).not.to.equal('new short name');
|
expect(res.shortName).not.to.equal('new short name');
|
||||||
|
|
||||||
expect(res.leader).to.eql({
|
expect(res.leader).to.eql({
|
||||||
_id: member._id,
|
_id: user._id,
|
||||||
id: member._id,
|
id: user._id,
|
||||||
profile: {name: member.profile.name},
|
profile: {name: user.profile.name},
|
||||||
auth: {
|
auth: {
|
||||||
local: {
|
local: {
|
||||||
username: member.auth.local.username,
|
username: user.auth.local.username,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
flags: {
|
flags: {
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ schema.pre('init', function ensureSummaryIsFetched (chal) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// A list of additional fields that cannot be updated (but can be set on creation)
|
// A list of additional fields that cannot be updated (but can be set on creation)
|
||||||
let noUpdate = ['group', 'official', 'shortName', 'prize'];
|
let noUpdate = ['group', 'leader', 'official', 'shortName', 'prize'];
|
||||||
schema.statics.sanitizeUpdate = function sanitizeUpdate (updateObj) {
|
schema.statics.sanitizeUpdate = function sanitizeUpdate (updateObj) {
|
||||||
return this.sanitize(updateObj, noUpdate);
|
return this.sanitize(updateObj, noUpdate);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user