diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-06-24 18:35:33 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-06-24 18:35:33 -0400 |
commit | 49d312d5a41ccfe23432ef0f00a6ae79c8fd558f (patch) | |
tree | 29817260c415d565847ea70834d4821821341fe5 /app/Model/TaskModificationModel.php | |
parent | 16a138c86f3216ecb97f80062cdc36d7ae8a57ed (diff) |
Added unit test when updating tags for a task
Diffstat (limited to 'app/Model/TaskModificationModel.php')
-rw-r--r-- | app/Model/TaskModificationModel.php | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/app/Model/TaskModificationModel.php b/app/Model/TaskModificationModel.php index 0fc3617e..1b176a41 100644 --- a/app/Model/TaskModificationModel.php +++ b/app/Model/TaskModificationModel.php @@ -25,6 +25,7 @@ class TaskModificationModel extends Base { $original_task = $this->taskFinderModel->getById($values['id']); + $this->updateTags($values, $original_task); $this->prepare($values); $result = $this->db->table(TaskModel::TABLE)->eq('id', $original_task['id'])->update($values); @@ -80,16 +81,11 @@ class TaskModificationModel extends Base /** * Prepare data before task modification * - * @access public - * @param array $values Form values + * @access protected + * @param array $values */ - public function prepare(array &$values) + protected function prepare(array &$values) { - if (isset($values['tags'])) { - $this->taskTagModel->save($values['project_id'], $values['id'], $values['tags']); - unset($values['tags']); - } - $values = $this->dateParser->convert($values, array('date_due')); $values = $this->dateParser->convert($values, array('date_started'), true); @@ -99,4 +95,21 @@ class TaskModificationModel extends Base $values['date_modification'] = time(); } + + /** + * Update tags + * + * @access protected + * @param array $values + * @param array $original_task + */ + protected function updateTags(array &$values, array $original_task) + { + if (isset($values['tags'])) { + $this->taskTagModel->save($original_task['project_id'], $values['id'], $values['tags']); + unset($values['tags']); + } else { + $this->taskTagModel->save($original_task['project_id'], $values['id'], array()); + } + } } |