Improve travis success rate

https://travis-ci.org/codecombat/codecombat/builds/96076589

Failures:
1) Recalculate Achievements remove earned achievements
  Message:
    Expected 1 to be 0.
  Stack:
    Error: Expected 1 to be 0.
...

Apparently EarnedAchievement creation from previous tests bleeds into this test case.
Adding a timeout to minimize the race condition problem here.
This commit is contained in:
Scott Erickson 2015-12-18 10:40:37 -08:00
parent 079109145f
commit def3e9a009

View file

@ -220,6 +220,7 @@ describe 'Recalculate Achievements', ->
EarnedAchievementHandler = require '../../../server/achievements/earned_achievement_handler'
it 'remove earned achievements', (done) ->
f = ->
clearModels [EarnedAchievement], (err) ->
expect(err).toBeNull()
EarnedAchievement.find {}, (err, earned) ->
@ -228,6 +229,7 @@ describe 'Recalculate Achievements', ->
User.update {}, {$set: {points: 0}}, {multi:true}, (err) ->
expect(err).toBeNull()
done()
setTimeout f, 100 # wait for previous tests to wrap up to avoid race condition
it 'can not be accessed by regular users', (done) ->
loginJoe -> request.post {uri:getURL '/admin/earned_achievement/recalculate'}, (err, res, body) ->