From 0448fdc56b9d7c58ac78d8375447c59b68702562 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 23 Jan 2016 12:04:10 -0500 Subject: Fix bug: Unable to unassign a task from the API --- tests/integration/TaskTest.php | 58 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 tests/integration/TaskTest.php (limited to 'tests/integration/TaskTest.php') diff --git a/tests/integration/TaskTest.php b/tests/integration/TaskTest.php new file mode 100644 index 00000000..20da12bd --- /dev/null +++ b/tests/integration/TaskTest.php @@ -0,0 +1,58 @@ +app->createProject('My project'); + $this->assertNotFalse($project_id); + + $user_id = $this->app->createUser('user0', 'password'); + $this->assertNotFalse($user_id); + + $this->assertTrue($this->app->addProjectUser($project_id, $user_id, 'project-member')); + + $task_id = $this->app->createTask(array('project_id' => $project_id, 'title' => 'My task')); + $this->assertNotFalse($task_id); + + $this->assertTrue($this->app->updateTask(array('id' => $task_id, 'project_id' => $project_id, 'owner_id' => $user_id))); + + $task = $this->app->getTask($task_id); + $this->assertEquals($user_id, $task['owner_id']); + } + + public function testChangeAssigneeToNotAssignableUser() + { + $project_id = $this->app->createProject('My project'); + $this->assertNotFalse($project_id); + + $task_id = $this->app->createTask(array('project_id' => $project_id, 'title' => 'My task')); + $this->assertNotFalse($task_id); + + $this->assertFalse($this->app->updateTask(array('id' => $task_id, 'project_id' => $project_id, 'owner_id' => 1))); + + $task = $this->app->getTask($task_id); + $this->assertEquals(0, $task['owner_id']); + } + + public function testChangeAssigneeToNobody() + { + $project_id = $this->app->createProject('My project'); + $this->assertNotFalse($project_id); + + $user_id = $this->app->createUser('user1', 'password'); + $this->assertNotFalse($user_id); + + $this->assertTrue($this->app->addProjectUser($project_id, $user_id, 'project-member')); + + $task_id = $this->app->createTask(array('project_id' => $project_id, 'title' => 'My task', 'owner_id' => $user_id)); + $this->assertNotFalse($task_id); + + $this->assertTrue($this->app->updateTask(array('id' => $task_id, 'project_id' => $project_id, 'owner_id' => 0))); + + $task = $this->app->getTask($task_id); + $this->assertEquals(0, $task['owner_id']); + } +} -- cgit v1.2.3 From ba5937b07490160affad8239a7a9e6227979f770 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 23 Jan 2016 12:29:44 -0500 Subject: Add new API procedures to move and duplicate tasks to another project --- ChangeLog | 2 +- app/Api/Task.php | 10 ++++++ doc/api-task-procedures.markdown | 76 +++++++++++++++++++++++++++++++++++++++- tests/integration/TaskTest.php | 38 ++++++++++++++++++++ 4 files changed, 124 insertions(+), 2 deletions(-) (limited to 'tests/integration/TaskTest.php') diff --git a/ChangeLog b/ChangeLog index db95e88b..a9510c00 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,7 +6,7 @@ New features: * Forgot Password * Add dropdown menu on each board column title to close all tasks * Add Malay language -* Add new API procedures for groups, roles and project permissions +* Add new API procedures for groups, roles, project permissions and to move/duplicate tasks to another project Improvements: diff --git a/app/Api/Task.php b/app/Api/Task.php index 97d89775..f132bcd6 100644 --- a/app/Api/Task.php +++ b/app/Api/Task.php @@ -64,6 +64,16 @@ class Task extends Base return $this->taskPosition->movePosition($project_id, $task_id, $column_id, $position, $swimlane_id); } + public function moveTaskToProject($task_id, $project_id, $swimlane_id = null, $column_id = null, $category_id = null, $owner_id = null) + { + return $this->taskDuplication->moveToProject($task_id, $project_id, $swimlane_id, $column_id, $category_id, $owner_id); + } + + public function duplicateTaskToProject($task_id, $project_id, $swimlane_id = null, $column_id = null, $category_id = null, $owner_id = null) + { + return $this->taskDuplication->duplicateToProject($task_id, $project_id, $swimlane_id, $column_id, $category_id, $owner_id); + } + public function createTask($title, $project_id, $color_id = '', $column_id = 0, $owner_id = 0, $creator_id = 0, $date_due = '', $description = '', $category_id = 0, $score = 0, $swimlane_id = 0, $recurrence_status = 0, $recurrence_trigger = 0, $recurrence_factor = 0, $recurrence_timeframe = 0, diff --git a/doc/api-task-procedures.markdown b/doc/api-task-procedures.markdown index f2ca54d1..49868e2a 100644 --- a/doc/api-task-procedures.markdown +++ b/doc/api-task-procedures.markdown @@ -525,7 +525,7 @@ Response example: ### moveTaskPosition -- Purpose: **Move a task to another column or another position** +- Purpose: **Move a task to another column, position or swimlane inside the same board** - Parameters: - **project_id** (integer, required) - **task_id** (integer, required) @@ -560,3 +560,77 @@ Response example: "result": true } ``` + +### moveTaskToProject + +- Purpose: **Move a task to another project** +- Parameters: + - **task_id** (integer, required) + - **project_id** (integer, required) + - **swimlane_id** (integer, optional) + - **column_id** (integer, optional) + - **category_id** (integer, optional) + - **owner_id** (integer, optional) +- Result on success: **true** +- Result on failure: **false** + +Request example: + +```json +{ + "jsonrpc": "2.0", + "method": "moveTaskToProject", + "id": 15775829, + "params": [ + 4, + 5 + ] +} +``` + +Response example: + +```json +{ + "jsonrpc": "2.0", + "id": 15775829, + "result": true +} +``` + +### duplicateTaskToProject + +- Purpose: **Move a task to another column or another position** +- Parameters: + - **task_id** (integer, required) + - **project_id** (integer, required) + - **swimlane_id** (integer, optional) + - **column_id** (integer, optional) + - **category_id** (integer, optional) + - **owner_id** (integer, optional) +- Result on success: **task_id** +- Result on failure: **false** + +Request example: + +```json +{ + "jsonrpc": "2.0", + "method": "duplicateTaskToProject", + "id": 1662458687, + "params": [ + 5, + 7 + ] +} +``` + +Response example: + +```json +{ + "jsonrpc": "2.0", + "id": 1662458687, + "result": 6 +} +``` diff --git a/tests/integration/TaskTest.php b/tests/integration/TaskTest.php index 20da12bd..6d500da4 100644 --- a/tests/integration/TaskTest.php +++ b/tests/integration/TaskTest.php @@ -55,4 +55,42 @@ class TaskTest extends Base $task = $this->app->getTask($task_id); $this->assertEquals(0, $task['owner_id']); } + + public function testMoveTaskToAnotherProject() + { + $project_id1 = $this->app->createProject('My project'); + $this->assertNotFalse($project_id1); + + $project_id2 = $this->app->createProject('My project'); + $this->assertNotFalse($project_id2); + + $task_id = $this->app->createTask(array('project_id' => $project_id1, 'title' => 'My task')); + $this->assertNotFalse($task_id); + + $this->assertTrue($this->app->moveTaskToProject($task_id, $project_id2)); + + $task = $this->app->getTask($task_id); + $this->assertEquals($project_id2, $task['project_id']); + } + + public function testMoveCopyToAnotherProject() + { + $project_id1 = $this->app->createProject('My project'); + $this->assertNotFalse($project_id1); + + $project_id2 = $this->app->createProject('My project'); + $this->assertNotFalse($project_id2); + + $task_id1 = $this->app->createTask(array('project_id' => $project_id1, 'title' => 'My task')); + $this->assertNotFalse($task_id1); + + $task_id2 = $this->app->duplicateTaskToProject($task_id1, $project_id2); + $this->assertNotFalse($task_id2); + + $task = $this->app->getTask($task_id1); + $this->assertEquals($project_id1, $task['project_id']); + + $task = $this->app->getTask($task_id2); + $this->assertEquals($project_id2, $task['project_id']); + } } -- cgit v1.2.3