mirror of
https://github.com/wassname/talk.git
synced 2026-07-02 23:22:24 +08:00
Fix routes and tests for asset status change.
This commit is contained in:
@@ -90,9 +90,9 @@ router.put('/:asset_id/settings', (req, res, next) => {
|
||||
});
|
||||
|
||||
router.put('/:asset_id/status', (req, res, next) => {
|
||||
// Update the asset status
|
||||
|
||||
Asset
|
||||
.update({id: req.params.asset_id}, {status: req.query.status})
|
||||
.changeOpenStatus(req.params.asset_id, req.query.status, req.query.closedMessage)
|
||||
.then(() => res.status(204).end())
|
||||
.catch((err) => next(err));
|
||||
});
|
||||
|
||||
@@ -89,7 +89,7 @@ router.post('/', wordlist.filter('body'), (req, res, next) => {
|
||||
if (asset.isClosed) {
|
||||
|
||||
// They have, ensure that we send back an error.
|
||||
return Promise.reject(new Error(`asset has commenting closed because: ${asset.closedMessage}`));
|
||||
return Promise.reject(new Error(`asset has commenting closed because: ${asset.statusClosedMessage}`));
|
||||
}
|
||||
|
||||
return asset;
|
||||
|
||||
@@ -199,8 +199,9 @@ describe('/api/v1/comments', () => {
|
||||
|
||||
it('shouldn\'t create a comment when the asset has expired commenting', () => {
|
||||
return Asset.create({
|
||||
closedAt: new Date().setDate(0),
|
||||
closedMessage: 'tests said expired!'
|
||||
status: 'closed',
|
||||
statusChangedAt: new Date().setDate(0),
|
||||
statusClosedMessage: 'tests said expired!'
|
||||
})
|
||||
.then((asset) => {
|
||||
return chai.request(app)
|
||||
|
||||
Reference in New Issue
Block a user