Merge branch 'develop'

This commit is contained in:
Tyler Renelle 2013-04-06 12:56:28 -04:00
commit 69d8d478da
3 changed files with 8 additions and 5 deletions

View file

@ -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'

View file

@ -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) ->

View file

@ -78,7 +78,7 @@
<option>{:hatchingPotion}</option>
{/each}
</select>
<button type=submit>Sprinkle</button>
<button type=submit>Pour</button>
</form>
{/if}
</div>