fix moment() bugs (word from the wise, moment() functions modify the

original object)
This commit is contained in:
Tyler Renelle
2012-09-24 17:26:25 -04:00
parent 33f8c43e93
commit 0f9b70daf2
3 changed files with 36 additions and 26 deletions
+5 -4
View File
@@ -141,8 +141,9 @@ describe 'User', ->
it 'calculates user.stats & task.value properly on cron', ->
[statsBefore, taskBefore] = pathSnapshots(['_user.stats', taskPath])
# Set lastCron to yesterday
today = moment().sod()
model.set '_user.lastCron', today.subtract('days',1).sod().toDate()
today = new moment()
yesterday = new moment().subtract('days',1)
model.set '_user.lastCron', yesterday.toDate()
# Run run
scoring.cron()
[statsAfter, taskAfter] = pathSnapshots(['_user.stats', taskPath])
@@ -152,9 +153,9 @@ describe 'User', ->
expect(today.diff(lastCron, 'days')).to.eql 0
# Should have updated points properly
expect(taskAfter.value).to.eql -1
expect(statsBefore.hp).to.be.lessThan statsAfter.hp
expect(statsBefore.hp).to.be.greaterThan statsAfter.hp
expect(taskBefore.value).to.eql 0
expect(taskAfter.value).to.eql -1
#TODO clicking repeat dates on newly-created item doesn't refresh until you refresh the page
#TODO dates on dailies is having issues, possibility: date cusps? my saturday exempts were set to exempt at 8pm friday