Fix user receiving Joined Challenged achievement when creating a challenge (#10559)

* Fix joinedChallenge achievement being awarded when creating a challenge

* Modify test to check that achievement is not awarded for creating a challenge
This commit is contained in:
Alex Figueroa
2018-07-30 07:00:05 -07:00
committed by Matteo Pagliazzi
parent 774a1d9a96
commit 5566460541
2 changed files with 2 additions and 4 deletions

View File

@@ -304,14 +304,14 @@ describe('POST /challenges', () => {
expect(groupLeader.challenges.length).to.equal(0);
});
it('awards achievement if this is creator\'s first challenge', async () => {
it('does not award joinedChallenge achievement for creating a challenge', async () => {
await groupLeader.post('/challenges', {
group: group._id,
name: 'Test Challenge',
shortName: 'TC Label',
});
groupLeader = await groupLeader.sync();
expect(groupLeader.achievements.joinedChallenge).to.be.true;
expect(groupLeader.achievements.joinedChallenge).to.not.be.true;
});
it('sets summary to challenges name when not supplied', async () => {

View File

@@ -79,8 +79,6 @@ export async function createChallenge (user, req, res) {
let challengeValidationErrors = challenge.validateSync();
if (challengeValidationErrors) throw challengeValidationErrors;
addUserJoinChallengeNotification(user);
let results = await Promise.all([challenge.save({
validateBeforeSave: false, // already validated
}), group.save(), user.save()]);