mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	#18 feature-update event example
This commit is contained in:
		
							parent
							
								
									dc54d8504a
								
							
						
					
					
						commit
						b575f646eb
					
				@ -34,7 +34,20 @@ module.exports = function (app) {
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    app.patch('/features/:id', function (req, res) {
 | 
					    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();
 | 
				
			||||||
 | 
					        // });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
				
			|||||||
@ -22,8 +22,22 @@ describe('The api', function () {
 | 
				
			|||||||
    it('creates new feature toggle', function (done) {
 | 
					    it('creates new feature toggle', function (done) {
 | 
				
			||||||
        request
 | 
					        request
 | 
				
			||||||
            .post('/features')
 | 
					            .post('/features')
 | 
				
			||||||
            .send({name: 'featureAss', 'status': 'off'})
 | 
					            .send({name: 'com.test.feature', 'status': 'off'})
 | 
				
			||||||
            .set('Content-Type', 'application/json')
 | 
					            .set('Content-Type', 'application/json')
 | 
				
			||||||
            .expect(201, done);
 | 
					            .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);
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user