Merge branch 'chimericdream-issues/4838' into develop

This commit is contained in:
Blade Barringer 2015-06-09 12:45:22 -05:00
commit ca72b9a9e1
3 changed files with 23 additions and 0 deletions

View file

@ -1,6 +1,7 @@
{
"messageLostItem": "Your <%= itemText %> broke.",
"messageTaskNotFound": "Task not found.",
"messageDuplicateTaskID": "A task with that ID already exists.",
"messageTagNotFound": "Tag not found.",
"messagePetNotFound": ":pet not found in user.items.pets",
"messageFoodNotFound": ":food not found in user.items.food",

View file

@ -596,6 +596,7 @@ api.wrap = (user, main=true) ->
addTask: (req, cb) ->
task = api.taskDefaults(req.body)
return cb?({code:409,message:i18n.t('messageDuplicateTaskID', req.language)}) if user.tasks[task.id]?
user["#{task.type}s"].unshift(task)
if user.preferences.newTaskEdit then task._editing = true
if user.preferences.tagsCollapsed then task._tags = true

View file

@ -97,6 +97,27 @@ describe "Todos", ->
expect(todo.value).to.equal 0
done()
it "Does not create a todo with an id that already exists", (done) ->
original_todo = {
type: "todo"
text: "original todo"
id: "custom-id"
}
duplicate_id_todo = {
type: "todo"
text: "not original todo"
id: "custom-id"
}
request.post(baseURL + "/user/tasks").send(
original_todo
).end (res) ->
request.post(baseURL + "/user/tasks").send(
duplicate_id_todo
).end (res) ->
expectCode res, 409
expect(res.body.err).to.eql('A task with that ID already exists.')
done()
describe "Updating todos", ->
it "Does not update id of todo", (done) ->
request.put(baseURL + "/user/tasks/" + todo.id).send(