From b575f646eb2e345aef4e44f440ae79c17ac7c9d2 Mon Sep 17 00:00:00 2001 From: svelovla Date: Tue, 21 Oct 2014 16:02:23 +0200 Subject: [PATCH] #18 feature-update event example --- unleash-server/lib/api.js | 15 ++++++++++++++- unleash-server/test/apiSpec.js | 16 +++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/unleash-server/lib/api.js b/unleash-server/lib/api.js index 4fa697dfdb..a4f86e7f95 100644 --- a/unleash-server/lib/api.js +++ b/unleash-server/lib/api.js @@ -34,7 +34,20 @@ module.exports = function (app) { }); app.patch('/features/:id', function (req, res) { - res.status(500).end(); + var body = req.body; + body.data.name = req.params.id; + var event = {}; + event.type = 'feature-update'; + event.user = req.connection.remoteAddress; + event.comment = body.comment; + event.data = body.data; + + // console.log(event); + + // db.save(event).then(function () { + res.status(204).end(); + // }); + }); }; diff --git a/unleash-server/test/apiSpec.js b/unleash-server/test/apiSpec.js index 0d1fd47229..6d565748d8 100644 --- a/unleash-server/test/apiSpec.js +++ b/unleash-server/test/apiSpec.js @@ -22,8 +22,22 @@ describe('The api', function () { it('creates new feature toggle', function (done) { request .post('/features') - .send({name: 'featureAss', 'status': 'off'}) + .send({name: 'com.test.feature', 'status': 'off'}) .set('Content-Type', 'application/json') .expect(201, done); }); + + it('change status of feature toggle', function (done) { + request + .patch('/features/com.test.feature') + .send({ + 'comment': 'patch test of com.test.feature', + data: { + 'status': 'on' + } + }) + .set('Content-Type', 'application/json') + .expect(204, done); + }); + }); \ No newline at end of file