From ec3b32fccbd352c02f45ff3f2d4bce23cc691cb9 Mon Sep 17 00:00:00 2001 From: Blade Barringer Date: Tue, 9 Jun 2015 12:44:49 -0500 Subject: [PATCH] Add test for preventing task with id that already exists --- test/api/todos.coffee | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/api/todos.coffee b/test/api/todos.coffee index 78271134ae..b5f8d7fe3e 100644 --- a/test/api/todos.coffee +++ b/test/api/todos.coffee @@ -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(