v3 adapt v2: lint client only shared ops and enable members integration tests

This commit is contained in:
Matteo Pagliazzi
2016-04-07 11:54:36 +02:00
parent d49847688e
commit 2d3fbe9f13
13 changed files with 121 additions and 108 deletions

View File

@@ -1,19 +1,21 @@
import i18n from '../i18n';
import { NotFound } from '../libs/errors';
import _ from 'lodash';
// TODO used only in client, move there?
module.exports = function(user, req, cb) {
var i, ref, task;
task = user.tasks[(ref = req.params) != null ? ref.id : void 0];
module.exports = function deleteTask (user, req = {}) {
let tid = _.get(req, 'params.id');
let task = user.tasks[tid];
if (!task) {
return typeof cb === "function" ? cb({
code: 404,
message: i18n.t('messageTaskNotFound', req.language)
}) : void 0;
throw new NotFound(i18n.t('messageTaskNotFound', req.language));
}
i = user[task.type + "s"].indexOf(task);
if (~i) {
user[task.type + "s"].splice(i, 1);
let index = user[`${task.type}s`].indexOf(task);
if (index !== -1) {
user[`${task.type}s`].splice(index, 1);
}
return typeof cb === "function" ? cb(null, {}) : void 0;
return {};
};