From 8391494b89b89d37e3bc91fea316a215eada949a Mon Sep 17 00:00:00 2001 From: Matteo Pagliazzi Date: Sun, 1 May 2016 14:15:26 +0200 Subject: [PATCH] v3: fix tags tests --- test/api/v3/integration/models/GET-model_paths.test.js | 4 +++- website/src/controllers/api-v3/tags.js | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/test/api/v3/integration/models/GET-model_paths.test.js b/test/api/v3/integration/models/GET-model_paths.test.js index 205269bcbe..0a9a94451a 100644 --- a/test/api/v3/integration/models/GET-model_paths.test.js +++ b/test/api/v3/integration/models/GET-model_paths.test.js @@ -23,7 +23,9 @@ describe('GET /models/:model/paths', () => { it(`returns the model paths for ${model}`, async () => { let res = await user.get(`/models/${model}/paths`); - expect(res._id).to.equal('String'); + if (model !== 'tag') expect(res._id).to.equal('String'); + if (model === 'tag') expect(res.id).to.equal('String'); + expect(res).to.not.have.keys('__v'); }); }); diff --git a/website/src/controllers/api-v3/tags.js b/website/src/controllers/api-v3/tags.js index e40a83b7e6..8d452154cd 100644 --- a/website/src/controllers/api-v3/tags.js +++ b/website/src/controllers/api-v3/tags.js @@ -5,6 +5,7 @@ import { NotFound, } from '../../libs/api-v3/errors'; import _ from 'lodash'; +import { removeFromArray } from '../../libs/api-v3/collectionManipulators'; let api = {}; @@ -134,9 +135,8 @@ api.deleteTag = { let validationErrors = req.validationErrors(); if (validationErrors) throw validationErrors; - let tag = _.find(user.tags, {id: req.params.tagId}); + let tag = removeFromArray(user.tags, { id: req.params.tagId }); if (!tag) throw new NotFound(res.t('tagNotFound')); - tag.remove(); // Remove from all the tasks TODO test await Tasks.Task.update({