diff --git a/routes/api/comments/index.js b/routes/api/comments/index.js index 2c9daa73f..428369ae1 100644 --- a/routes/api/comments/index.js +++ b/routes/api/comments/index.js @@ -26,11 +26,11 @@ router.get('/:comment_id', (req, res, next) => { router.post('/', (req, res, next) => { let comment = new Comment({ - body: req.query.body, - author_id: req.query.author_id, - asset_id: req.query.asset_id, - parent_id: req.query.parent_id, - status: req.query.status + body: req.body.body, + author_id: req.body.author_id, + asset_id: req.body.asset_id, + parent_id: req.body.parent_id, + status: req.body.status }); comment.save().then(({id}) => { res.status(200).send(id); @@ -39,13 +39,13 @@ router.post('/', (req, res, next) => { }); }); -router.put('/:comment_id', (req, res, next) => { +router.post('/:comment_id', (req, res, next) => { Comment.findById(req.params.comment_id).then((comment) => { - comment.body = req.query.body; - comment.author_id = req.query.author_id; - comment.asset_id = req.query.asset_id; - comment.parent_id = req.query.parent_id; - comment.status = req.query.status; + comment.body = req.body.body; + comment.author_id = req.body.author_id; + comment.asset_id = req.body.asset_id; + comment.parent_id = req.body.parent_id; + comment.status = req.body.status; comment.save().then((comment) => { res.status(200).send(comment); diff --git a/tests/routes/api/comments/index.js b/tests/routes/api/comments/index.js index ac8cc5327..c3694d95e 100644 --- a/tests/routes/api/comments/index.js +++ b/tests/routes/api/comments/index.js @@ -94,7 +94,7 @@ describe('Post /comments', () => { it('it should create a comment', function(done) { chai.request(app) .post('/api/v1/comments') - .query({'body': 'Something body.', 'author_id': '123', 'asset_id': '1', 'parent_id': ''}) + .send({'body': 'Something body.', 'author_id': '123', 'asset_id': '1', 'parent_id': ''}) .end(function(err, res){ expect(res).to.have.status(200) done() @@ -200,8 +200,8 @@ describe('Put /:comment_id', () => { it('it should update comment', function(done) { chai.request(app) - .put('/api/v1/comments/abc') - .query({'body': 'Something body.', 'author_id': '123', 'asset_id': '1', 'parent_id': ''}) + .post('/api/v1/comments/abc') + .send({'body': 'Something body.', 'author_id': '123', 'asset_id': '1', 'parent_id': ''}) .end(function(err, res){ expect(res).to.have.status(200) done()