Enable guild challenge prize to use guild bank gems (#7840)

* add leader property to getGroups

* Add test coverage
This commit is contained in:
Oziris 2016-08-01 16:31:31 -03:00 committed by Blade Barringer
parent a8226b2363
commit d51bd68201
3 changed files with 30 additions and 4 deletions

View file

@ -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,
});
});
});
});

View file

@ -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,
});
});

View file

@ -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();