Feature: Edit a project
As a vision user I want to update a project So that I can change the repositories I monitor
Let's add a test to our existing set of tests ./test/project.js
for our Edit a project
feature. This resource will PUT a project to route /project/:id
, and return a 204 No Content
status:
describe('when updating an existing resource /project/:id', function(){ var project = { name: "new test name" , user: login.user , token: login.token , repositories : [ "12345", "9898" ] }; it('should respond with 204', function(done){ request(app) .put('/project/' + id) .send(project) .expect(204, done); }); });
Let's implement the Edit a project
feature ./lib/project/index.js
and add a put
function. We attempt to retrieve a project by calling the static function Project.findOne
. If we get an error, we return it; if we cannot find the project, we return null. If we find the project, we update it and return the project:
Project.prototype.put = function...