CHanges from query to body for post/put.

This commit is contained in:
gaba
2016-11-07 11:34:34 -08:00
parent 38692ccd30
commit 16e7a6c868
2 changed files with 14 additions and 14 deletions
+11 -11
View File
@@ -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);
+3 -3
View File
@@ -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()