fix api + tests

This commit is contained in:
Tyler Renelle 2013-05-25 19:42:59 +01:00
parent 20addd24c7
commit f0c50e1cfe
3 changed files with 6 additions and 6 deletions

View file

@ -26,7 +26,7 @@ module.exports.score = (model, taskId, direction, allowUndo=false) ->
model.set '_undo', {stats:_.cloneDeep(uObj.stats), task:tObjBefore, timeoutId: timeoutId}
paths = {}
delta = algos.score(uObj, tObj, direction, {paths:paths})
delta = algos.score(uObj, tObj, direction, {paths})
_.each paths, (v,k) -> user.set(k,helpers.dotGet(k, uObj)); true
model.set('_streakBonus', uObj._tmp.streakBonus) if uObj._tmp?.streakBonus
if uObj._tmp?.drop and $?

View file

@ -3,7 +3,7 @@ router = new express.Router()
_ = require 'lodash'
algos = require 'habitrpg-shared/script/algos'
{ tnl } = algos
helpers = require 'habitrpg-shared/script/helpers'
validator = require 'derby-auth/node_modules/validator'
check = validator.check
sanitize = validator.sanitize
@ -52,7 +52,7 @@ auth = (req, res, next) ->
router.get '/user', auth, (req, res) ->
user = req.userObj
user.stats.toNextLevel = tnl user.stats.lvl
user.stats.toNextLevel = algos.tnl user.stats.lvl
user.stats.maxHealth = 50
delete user.apiToken

View file

@ -373,13 +373,13 @@ describe 'API', ->
expect(res.statusCode).to.be 201
tasks = res.body.tasks
expect(_.first(tasks,{id:habitId})).to.eql {id: habitId,text: 'hello2',notes: 'note2'}
expect(_.find(tasks,{id:habitId})).to.eql {id: habitId,text: 'hello2',notes: 'note2'}
foundNewTask = _.findWhere(tasks,{text:'new task2'})
foundNewTask = _.find(tasks,{text:'new task2'})
expect(foundNewTask.text).to.be 'new task2'
expect(foundNewTask.notes).to.be 'notes2'
found = _.findWhere(res.body.tasks, {id:dailyId})
found = _.find(res.body.tasks, {id:dailyId})
expect(found).to.not.be.ok()
query.fetch (err, user) ->