Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit da0ceef

Browse files
author
vikasrohit
committedJan 19, 2016
Merge pull request #665 from appirio-tech/feature/sup-2994-empty-page-my-past-challenges
SUP-2994, My Challenges | | Empty page when loading past challenges
2 parents 1cc0149 + aeeee4c commit da0ceef

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed
 

‎app/services/challenge.service.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@
189189
return submission.type === CONSTANTS.SUBMISSION_TYPE_CONTEST && submission.placement;
190190
}), 'placement').placement;
191191
}
192-
if (challenge.track === 'DEVELOP' && challenge.subTrack === 'FIRST_2_FINISH') {
192+
if (challenge.track === 'DEVELOP' && challenge.subTrack === 'FIRST_2_FINISH'
193+
&& challenge.userDetails.submissions && challenge.userDetails.submissions.length > 0) {
193194
challenge.highestPlacement = _.min(challenge.userDetails.submissions.filter(function(submission) {
194195
return submission.type === CONSTANTS.SUBMISSION_TYPE_CONTEST
195196
&& submission.status === CONSTANTS.STATUS_ACTIVE && submission.placement;

‎app/services/challenge.service.spec.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ describe('Challenge Service', function() {
326326
expect(challenge.userHasSubmitterRole).to.exist.to.true;
327327
});
328328

329-
it('processPastChallenges should process a not completed DEVELOP/FIRST_2_FINISH challenge ', function() {
329+
it('processPastChallenges should process a not completed (empty submissions) DEVELOP/FIRST_2_FINISH challenge ', function() {
330330
var challenges = [
331331
{
332332
id: 30041345,
@@ -348,6 +348,28 @@ describe('Challenge Service', function() {
348348
expect(challenge.userHasSubmitterRole).to.exist.to.true;
349349
});
350350

351+
it('processPastChallenges should process a not completed(null submissions) DEVELOP/FIRST_2_FINISH challenge ', function() {
352+
var challenges = [
353+
{
354+
id: 30041345,
355+
name: 'Mock Challenge 1',
356+
track: 'DEVELOP',
357+
subTrack: 'FIRST_2_FINISH',
358+
userDetails: {
359+
hasUserSubmittedForReview: false,
360+
roles: ['Submitter'],
361+
submissions: null
362+
}
363+
}
364+
];
365+
ChallengeService.processPastChallenges(challenges);
366+
var challenge = challenges[0];
367+
expect(challenge.highestPlacement).not.to.exist;
368+
expect(challenge.wonFirst).to.exist.to.false;
369+
expect(challenge.userStatus).to.exist.to.equal('NOT_FINISHED');
370+
expect(challenge.userHasSubmitterRole).to.exist.to.true;
371+
});
372+
351373
it('processPastChallenges should process a DEVELOP/FIRST_2_FINISH challenge for a non submitter user ', function() {
352374
var challenges = [
353375
{

0 commit comments

Comments
 (0)
This repository has been archived.