Merge branch 'master' into production

This commit is contained in:
Scott Erickson 2016-05-25 10:30:01 -07:00
commit 0bddd45e97
2 changed files with 9 additions and 1 deletions

View file

@ -52,7 +52,9 @@ module.exports =
classroomMap[classroom.id] = classroom for classroom in classrooms classroomMap[classroom.id] = classroom for classroom in classrooms
levelOriginal = level.get('original') levelOriginal = level.get('original')
for courseInstance in courseInstances for courseInstance in courseInstances
classroom = classroomMap[courseInstance.get('classroomID').toString()] classroomID = courseInstance.get('classroomID')
continue unless classroomID
classroom = classroomMap[classroomID.toString()]
courseID = courseInstance.get('courseID') courseID = courseInstance.get('courseID')
classroomCourse = _.find(classroom.get('courses'), (c) -> c._id.equals(courseID)) classroomCourse = _.find(classroom.get('courses'), (c) -> c._id.equals(courseID))
for courseLevel in classroomCourse.levels for courseLevel in classroomCourse.levels

View file

@ -80,6 +80,12 @@ describe 'GET /db/level/:handle/session', ->
expect(res.statusCode).toBe(200) expect(res.statusCode).toBe(200)
expect(body.codeLanguage).toBe('python') expect(body.codeLanguage).toBe('python')
done() done()
it 'does not break if the user has a courseInstance without an associated classroom', utils.wrap (done) ->
yield @courseInstance.update({$unset: {classroomID: ''}})
[res, body] = yield request.getAsync { uri: @url, json: true }
expect(res.statusCode).toBe(402)
done()
it 'returns 402 if the user is not in a course with that level', utils.wrap (done) -> it 'returns 402 if the user is not in a course with that level', utils.wrap (done) ->
otherStudent = yield utils.initUser({role: 'student'}) otherStudent = yield utils.initUser({role: 'student'})