add tests for GET challenges/:challengeId

This commit is contained in:
Matteo Pagliazzi
2016-02-10 16:10:00 +01:00
parent 19a709c360
commit 02a61e260b
2 changed files with 142 additions and 2 deletions

View File

@@ -307,11 +307,12 @@ api.getChallenge = {
let challengeId = req.params.challengeId;
let challenge = await Challenge.findById(challengeId)
// .populate('leader', nameFields) // don't populate the group as we'll fetch it manually later
// Don't populate the group as we'll fetch it manually later
// .populate('leader', nameFields)
.exec();
if (!challenge) throw new NotFound(res.t('challengeNotFound'));
// Fetching basicGroupFields
// Fetching basic group data
let group = await Group.getGroup({user, groupId: challenge.group, fields: basicGroupFields, optionalMembership: true});
if (!group || !challenge.canView(user, group)) throw new NotFound(res.t('challengeNotFound'));