Skip to content

Commit

Permalink
#18 feature-update event example
Browse files Browse the repository at this point in the history
  • Loading branch information
svelovla authored and ivarconr committed Feb 20, 2020
1 parent c2b2367 commit 89344cf
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
15 changes: 14 additions & 1 deletion unleash-server/lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
// });

});

};
Expand Down
16 changes: 15 additions & 1 deletion unleash-server/test/apiSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

});

0 comments on commit 89344cf

Please sign in to comment.