diff --git a/test/api/v3/integration/challenges/GET-challenges_challengeId.test.js b/test/api/v3/integration/challenges/GET-challenges_challengeId.test.js index 33b329300a..4bbbd001ba 100644 --- a/test/api/v3/integration/challenges/GET-challenges_challengeId.test.js +++ b/test/api/v3/integration/challenges/GET-challenges_challengeId.test.js @@ -46,7 +46,14 @@ describe('GET /challenges/:challengeId', () => { id: groupLeader._id, profile: {name: groupLeader.profile.name}, }); - expect(chal.group).to.eql(_.pick(group, ['_id', 'id', 'name', 'type', 'privacy'])); + expect(chal.group).to.eql({ + _id: group._id, + id: group.id, + name: group.name, + type: group.type, + privacy: group.privacy, + leader: groupLeader.id, + }); }); }); @@ -91,7 +98,14 @@ describe('GET /challenges/:challengeId', () => { id: groupLeader._id, profile: {name: groupLeader.profile.name}, }); - expect(chal.group).to.eql(_.pick(group, ['_id', 'id', 'name', 'type', 'privacy'])); + expect(chal.group).to.eql({ + _id: group._id, + id: group.id, + name: group.name, + type: group.type, + privacy: group.privacy, + leader: groupLeader.id, + }); }); }); @@ -136,7 +150,14 @@ describe('GET /challenges/:challengeId', () => { id: groupLeader.id, profile: {name: groupLeader.profile.name}, }); - expect(chal.group).to.eql(_.pick(group, ['_id', 'id', 'name', 'type', 'privacy'])); + expect(chal.group).to.eql({ + _id: group._id, + id: group.id, + name: group.name, + type: group.type, + privacy: group.privacy, + leader: groupLeader.id, + }); }); }); }); diff --git a/test/api/v3/integration/challenges/GET-challenges_user.test.js b/test/api/v3/integration/challenges/GET-challenges_user.test.js index b46367f46f..7379718412 100644 --- a/test/api/v3/integration/challenges/GET-challenges_user.test.js +++ b/test/api/v3/integration/challenges/GET-challenges_user.test.js @@ -45,6 +45,7 @@ describe('GET challenges/user', () => { type: publicGuild.type, privacy: publicGuild.privacy, name: publicGuild.name, + leader: publicGuild.leader._id, }); }); @@ -64,6 +65,7 @@ describe('GET challenges/user', () => { type: publicGuild.type, privacy: publicGuild.privacy, name: publicGuild.name, + leader: publicGuild.leader._id, }); let foundChallenge2 = _.find(challenges, { _id: challenge2._id }); expect(foundChallenge2).to.exist; @@ -78,6 +80,7 @@ describe('GET challenges/user', () => { type: publicGuild.type, privacy: publicGuild.privacy, name: publicGuild.name, + leader: publicGuild.leader._id, }); }); @@ -97,6 +100,7 @@ describe('GET challenges/user', () => { type: publicGuild.type, privacy: publicGuild.privacy, name: publicGuild.name, + leader: publicGuild.leader._id, }); let foundChallenge2 = _.find(challenges, { _id: challenge2._id }); expect(foundChallenge2).to.exist; @@ -111,6 +115,7 @@ describe('GET challenges/user', () => { type: publicGuild.type, privacy: publicGuild.privacy, name: publicGuild.name, + leader: publicGuild.leader._id, }); }); diff --git a/website/server/models/group.js b/website/server/models/group.js index 16a432e399..fc51fef7cb 100644 --- a/website/server/models/group.js +++ b/website/server/models/group.js @@ -95,7 +95,7 @@ schema.statics.sanitizeUpdate = function sanitizeUpdate (updateObj) { }; // Basic fields to fetch for populating a group info -export let basicFields = 'name type privacy'; +export let basicFields = 'name type privacy leader'; schema.pre('remove', true, async function preRemoveGroup (next, done) { next();