diff --git a/app/modules/home/home.service.coffee b/app/modules/home/home.service.coffee index 31b55ce0..625b31a2 100644 --- a/app/modules/home/home.service.coffee +++ b/app/modules/home/home.service.coffee @@ -68,28 +68,35 @@ class HomeService extends taiga.Service watching = workInProgress.get("watching") if watching.get("userStories") - _duties = watching.get("userStories").map (duty) -> + _duties = watching.get("userStories").filter (duty) -> + return !!projectsById.get(String(duty.get('project'))) + + _duties = _duties.map (duty) -> return _attachProjectInfoToDuty(duty, "userstories") watching = watching.set("userStories", _duties) if watching.get("tasks") - _duties = watching.get("tasks").map (duty) -> + _duties = watching.get("tasks").filter (duty) -> + return !!projectsById.get(String(duty.get('project'))) + + _duties = _duties.map (duty) -> return _attachProjectInfoToDuty(duty, "tasks") watching = watching.set("tasks", _duties) if watching.get("issues") - _duties = watching.get("issues").map (duty) -> + _duties = watching.get("issues").filter (duty) -> + return !!projectsById.get(String(duty.get('project'))) + + _duties = _duties.map (duty) -> return _attachProjectInfoToDuty(duty, "issues") watching = watching.set("issues", _duties) - workInProgress = workInProgress.set("assignedTo", assignedTo) workInProgress = workInProgress.set("watching", watching) - getWorkInProgress: (userId) -> projectsById = Immutable.Map() diff --git a/app/modules/home/home.service.spec.coffee b/app/modules/home/home.service.spec.coffee index de5782d5..24b1f01f 100644 --- a/app/modules/home/home.service.spec.coffee +++ b/app/modules/home/home.service.spec.coffee @@ -80,9 +80,25 @@ describe "tgHome", -> {id: 2, name: "fake2", slug: "project-2"} ])) - mocks.resources.userstories.listInAllProjects.promise() + mocks.resources.userstories.listInAllProjects + .withArgs(sinon.match({ + is_closed: false + assigned_to: userId + })) + .promise() .resolve(Immutable.fromJS([{id: 1, ref: 1, project: "1"}])) + mocks.resources.userstories.listInAllProjects + .withArgs(sinon.match({ + is_closed: false + watchers: userId + })) + .promise() + .resolve(Immutable.fromJS([ + {id: 1, ref: 1, project: "1"}, + {id: 2, ref: 2, project: "10"} # the user is not member of this project + ])) + mocks.resources.tasks.listInAllProjects.promise() .resolve(Immutable.fromJS([{id: 2, ref: 2, project: "1"}]))