mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-04-14 19:56:23 +00:00
Fix bug of incomplete TODOs not gaining value on cron
This commit is contained in:
parent
393033b1c2
commit
9811117acd
3 changed files with 33 additions and 21 deletions
|
|
@ -154,7 +154,7 @@ module.exports.tally = function(user, momentDate) {
|
|||
var expTally, lvl, todoTally;
|
||||
todoTally = 0;
|
||||
_.each(user.get('tasks'), function(taskObj, taskId, list) {
|
||||
var absVal, completed, dayMapping, repeat, task, type, value, _ref;
|
||||
var absVal, completed, dayMapping, dueToday, repeat, task, type, value, _ref;
|
||||
if (taskObj.id == null) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -172,7 +172,8 @@ module.exports.tally = function(user, momentDate) {
|
|||
6: 's',
|
||||
7: 'su'
|
||||
};
|
||||
if (repeat && repeat[dayMapping[momentDate.day()]] === true) {
|
||||
dueToday = repeat && repeat[dayMapping[momentDate.day()]] === true;
|
||||
if (dueToday || type === 'todo') {
|
||||
score({
|
||||
user: user,
|
||||
task: task,
|
||||
|
|
|
|||
|
|
@ -150,7 +150,8 @@ module.exports.tally = (user, momentDate) ->
|
|||
# but not for Todos (just increase todo's value)
|
||||
unless completed
|
||||
dayMapping = {0:'su',1:'m',2:'t',3:'w',4:'th',5:'f',6:'s',7:'su'}
|
||||
if repeat && repeat[dayMapping[momentDate.day()]]==true
|
||||
dueToday = (repeat && repeat[dayMapping[momentDate.day()]]==true)
|
||||
if dueToday or type=='todo'
|
||||
score({user:user, task:task, direction:'down', cron:true})
|
||||
if type == 'daily'
|
||||
task.push "history", { date: new Date(momentDate), value: value }
|
||||
|
|
|
|||
|
|
@ -7,29 +7,39 @@ casper = require("casper").create()
|
|||
casper.start url, ->
|
||||
@test.assertTitle "HabitRPG", "homepage title is the one expected"
|
||||
|
||||
# ---------- Todos gain delta on cron ------------
|
||||
casper.then ->
|
||||
todoBefore = @evaluate -> window.DERBY.model.get('_todoList')[0]
|
||||
@then ->
|
||||
@evaluate ->
|
||||
window.DERBY.model.set('_user.lastCron', new Date('09/17/2012'))
|
||||
@then -> @reload()
|
||||
@then ->
|
||||
todoAfter = @evaluate -> window.DERBY.model.get('_todoList')[0]
|
||||
@then -> @test.assert(todoBefore.value > todoAfter.value, "Incomplete TODO gained value on cron")
|
||||
|
||||
# ---------- User Death ------------
|
||||
casper.then ->
|
||||
@repeat 55, ->
|
||||
@click '.habits a[data-direction="down"]'
|
||||
|
||||
casper.then ->
|
||||
userStats = @evaluate ->
|
||||
window.DERBY.model.get('_user.stats')
|
||||
utils.dump userStats
|
||||
|
||||
@test.assert(@visible('#dead-modal'), 'Revive Modal Visible')
|
||||
@test.assert(userStats.hp == 0, 'User HP: 0')
|
||||
@test.assert(userStats.lvl == 0, 'User Lvl: 0')
|
||||
@test.assert(userStats.money == 0, 'User GP: 0')
|
||||
# casper.then ->
|
||||
# @repeat 55, ->
|
||||
# @click '.habits a[data-direction="down"]'
|
||||
#
|
||||
# casper.then ->
|
||||
# userStats = @evaluate ->
|
||||
# window.DERBY.model.get('_user.stats')
|
||||
# utils.dump userStats
|
||||
#
|
||||
# @test.assert(@visible('#dead-modal'), 'Revive Modal Visible')
|
||||
# @test.assert(userStats.hp == 0, 'User HP: 0')
|
||||
# @test.assert(userStats.lvl == 0, 'User Lvl: 0')
|
||||
# @test.assert(userStats.money == 0, 'User GP: 0')
|
||||
|
||||
# ---------- Misc Pages ------------
|
||||
|
||||
# casper.thenOpen "#{url}/terms", ->
|
||||
# @test.assertTitle "Terms Of Use", "terms page works"
|
||||
#
|
||||
# casper.thenOpen "#{url}/privacy", ->
|
||||
# @test.assertTitle "Privacy Policy", "privacy page works"
|
||||
casper.thenOpen "#{url}/terms", ->
|
||||
@test.assertTitle "Terms Of Use", "terms page works"
|
||||
|
||||
casper.thenOpen "#{url}/privacy", ->
|
||||
@test.assertTitle "Privacy Policy", "privacy page works"
|
||||
|
||||
casper.run ->
|
||||
@test.renderResults true
|
||||
Loading…
Reference in a new issue