Fix routes and tests for asset status change.

This commit is contained in:
gaba
2016-12-10 14:01:24 -10:00
parent 81071eacd6
commit 5e21102c2f
3 changed files with 6 additions and 5 deletions
+2 -2
View File
@@ -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));
});
+1 -1
View File
@@ -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;
+3 -2
View File
@@ -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)