Skip to content

Commit

Permalink
Fixed task removal.
Browse files Browse the repository at this point in the history
Needed to remove form the redundant subtasks data structure too.
  • Loading branch information
jimfulton committed Jul 2, 2017
1 parent 3e20e2f commit 328f215
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
11 changes: 9 additions & 2 deletions server/twotieredkanban/board.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,15 @@ def restore_feature(self, feature_id):

def remove(self, task_id):
task = self.tasks[task_id]
for subtask in self.subtasks.pop(task.id, ()):
self.tasks.remove(subtask)
if task.parent:
self.subtasks[task.parent.id] = tuple(
t for t in self.subtasks[task.parent.id]
if t is not task
)
else:
for subtask in self.subtasks.pop(task.id, ()):
self.tasks.remove(subtask)

self.tasks.remove(task)

class TaskTypeError(TypeError):
Expand Down
13 changes: 13 additions & 0 deletions server/twotieredkanban/tests/testboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,19 @@ def test_remove_feature(self):
set(self.updates()['tasks']['removals']))
self.assertEqual(len(self.board.tasks), 0)

def test_remove_task_then_feature(self):
self.board.new_project("Feature", 0)
[fid] = [t.id for t in self.updates()['tasks']['adds']]
self.board.new_task(fid, "t1", 0)
self.board.new_task(fid, "t2", 0)
t1id, t2id = [t.id for t in self.updates()['tasks']['adds']]
self.board.remove(t1id)
self.board.remove(fid)
self.assertEqual(
set([fid, t1id, t2id]),
set(self.updates()['tasks']['removals']))
self.assertEqual(len(self.board.tasks), 0)


sample_description = """
<h1>Heading large</h1>
Expand Down

0 comments on commit 328f215

Please sign in to comment.