From 5e21102c2fb9573ec9bb650555da1cd6ea02a971 Mon Sep 17 00:00:00 2001 From: gaba Date: Sat, 10 Dec 2016 14:01:24 -1000 Subject: [PATCH] Fix routes and tests for asset status change. --- routes/api/asset/index.js | 4 ++-- routes/api/comments/index.js | 2 +- tests/routes/api/comments/index.js | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/routes/api/asset/index.js b/routes/api/asset/index.js index 2ddc3ea23..ebdcf038d 100644 --- a/routes/api/asset/index.js +++ b/routes/api/asset/index.js @@ -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)); }); diff --git a/routes/api/comments/index.js b/routes/api/comments/index.js index 168b89fc3..fad9083cc 100644 --- a/routes/api/comments/index.js +++ b/routes/api/comments/index.js @@ -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; diff --git a/tests/routes/api/comments/index.js b/tests/routes/api/comments/index.js index b3e4e2675..4787e4d58 100644 --- a/tests/routes/api/comments/index.js +++ b/tests/routes/api/comments/index.js @@ -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)