mirror of
https://github.com/wassname/talk.git
synced 2026-07-07 21:18:57 +08:00
CHanges from query to body for post/put.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user