diff --git a/src/server/api.coffee b/src/server/api.coffee index 5f7b31e571..af8b1312ae 100644 --- a/src/server/api.coffee +++ b/src/server/api.coffee @@ -84,12 +84,13 @@ validateTask = (req, res, next) -> type = undefined delete newTask.type else if req.method is 'POST' + newTask.value = sanitize(value).toInt() + newTask.value = 0 if isNaN newTask.value unless /^(habit|todo|daily|reward)$/.test type return res.json 400, err: 'type must be habit, todo, daily, or reward' - text = sanitize(text).xss() - notes = sanitize(notes).xss() - value = sanitize(value).toInt() + newTask.text = sanitize(text).xss() if typeof text is "string" + newTask.notes = sanitize(notes).xss() if typeof notes is "string" switch type when 'habit' diff --git a/test/api.mocha.coffee b/test/api.mocha.coffee index 929cbfa3cf..0716d099e9 100644 --- a/test/api.mocha.coffee +++ b/test/api.mocha.coffee @@ -159,6 +159,8 @@ describe 'API', -> expect(res.body.id).not.to.be.empty() # Ensure that user owns the newly created object expect(user.get().tasks[res.body.id]).to.be.an('object') + # Ensure that value gets set to 0 since not otherwise specified + expect(user.get().tasks[res.body.id].value).to.be.equal(0) done() it 'PUT /api/v1/user/task/:id', (done) -> diff --git a/views/app/pets.html b/views/app/pets.html index 8bd02bb78c..d68f41ea38 100644 --- a/views/app/pets.html +++ b/views/app/pets.html @@ -78,7 +78,7 @@ {/each} - + {/if} @@ -98,4 +98,4 @@ {else}

You don't have any pets yet.

- {/} \ No newline at end of file + {/}