Fix bug: No creator when duplicating a task
This commit is contained in:
@@ -152,7 +152,6 @@ class Task extends Base
|
|||||||
{
|
{
|
||||||
$project = $this->getProject();
|
$project = $this->getProject();
|
||||||
$values = $this->request->getValues();
|
$values = $this->request->getValues();
|
||||||
$values['creator_id'] = $this->userSession->getId();
|
|
||||||
|
|
||||||
list($valid, $errors) = $this->taskValidator->validateCreation($values);
|
list($valid, $errors) = $this->taskValidator->validateCreation($values);
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class TaskCreation extends Base
|
|||||||
$this->dateParser->convert($values, array('date_due'));
|
$this->dateParser->convert($values, array('date_due'));
|
||||||
$this->dateParser->convert($values, array('date_started'), true);
|
$this->dateParser->convert($values, array('date_started'), true);
|
||||||
$this->removeFields($values, array('another_task'));
|
$this->removeFields($values, array('another_task'));
|
||||||
$this->resetFields($values, array('owner_id', 'swimlane_id', 'date_due', 'score', 'category_id', 'time_estimated'));
|
$this->resetFields($values, array('creator_id', 'owner_id', 'swimlane_id', 'date_due', 'score', 'category_id', 'time_estimated'));
|
||||||
|
|
||||||
if (empty($values['column_id'])) {
|
if (empty($values['column_id'])) {
|
||||||
$values['column_id'] = $this->board->getFirstColumn($values['project_id']);
|
$values['column_id'] = $this->board->getFirstColumn($values['project_id']);
|
||||||
@@ -60,6 +60,10 @@ class TaskCreation extends Base
|
|||||||
$values['title'] = t('Untitled');
|
$values['title'] = t('Untitled');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->userSession->isLogged()) {
|
||||||
|
$values['creator_id'] = $this->userSession->getId();
|
||||||
|
}
|
||||||
|
|
||||||
$values['swimlane_id'] = empty($values['swimlane_id']) ? 0 : $values['swimlane_id'];
|
$values['swimlane_id'] = empty($values['swimlane_id']) ? 0 : $values['swimlane_id'];
|
||||||
$values['date_creation'] = time();
|
$values['date_creation'] = time();
|
||||||
$values['date_modification'] = $values['date_creation'];
|
$values['date_modification'] = $values['date_creation'];
|
||||||
|
|||||||
@@ -175,6 +175,28 @@ class TaskCreationTest extends Base
|
|||||||
$this->assertEquals(1, $task['creator_id']);
|
$this->assertEquals(1, $task['creator_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testThatCreatorIsDefined()
|
||||||
|
{
|
||||||
|
$p = new Project($this->container);
|
||||||
|
$tc = new TaskCreation($this->container);
|
||||||
|
$tf = new TaskFinder($this->container);
|
||||||
|
|
||||||
|
$_SESSION = array();
|
||||||
|
$_SESSION['user']['id'] = 1;
|
||||||
|
|
||||||
|
$this->assertEquals(1, $p->create(array('name' => 'test')));
|
||||||
|
$this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test')));
|
||||||
|
|
||||||
|
$task = $tf->getById(1);
|
||||||
|
$this->assertNotEmpty($task);
|
||||||
|
$this->assertNotFalse($task);
|
||||||
|
|
||||||
|
$this->assertEquals(1, $task['id']);
|
||||||
|
$this->assertEquals(1, $task['creator_id']);
|
||||||
|
|
||||||
|
$_SESSION = array();
|
||||||
|
}
|
||||||
|
|
||||||
public function testColumnId()
|
public function testColumnId()
|
||||||
{
|
{
|
||||||
$p = new Project($this->container);
|
$p = new Project($this->container);
|
||||||
|
|||||||
@@ -15,6 +15,36 @@ use Model\Swimlane;
|
|||||||
|
|
||||||
class TaskDuplicationTest extends Base
|
class TaskDuplicationTest extends Base
|
||||||
{
|
{
|
||||||
|
public function testThatDuplicateDefineCreator()
|
||||||
|
{
|
||||||
|
$td = new TaskDuplication($this->container);
|
||||||
|
$tc = new TaskCreation($this->container);
|
||||||
|
$tf = new TaskFinder($this->container);
|
||||||
|
$p = new Project($this->container);
|
||||||
|
|
||||||
|
$this->assertEquals(1, $p->create(array('name' => 'test1')));
|
||||||
|
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1)));
|
||||||
|
|
||||||
|
$task = $tf->getById(1);
|
||||||
|
$this->assertNotEmpty($task);
|
||||||
|
$this->assertEquals(1, $task['position']);
|
||||||
|
$this->assertEquals(1, $task['project_id']);
|
||||||
|
$this->assertEquals(0, $task['creator_id']);
|
||||||
|
|
||||||
|
$_SESSION = array();
|
||||||
|
$_SESSION['user']['id'] = 1;
|
||||||
|
|
||||||
|
// We duplicate our task
|
||||||
|
$this->assertEquals(2, $td->duplicate(1));
|
||||||
|
|
||||||
|
// Check the values of the duplicated task
|
||||||
|
$task = $tf->getById(2);
|
||||||
|
$this->assertNotEmpty($task);
|
||||||
|
$this->assertEquals(1, $task['creator_id']);
|
||||||
|
|
||||||
|
$_SESSION = array();
|
||||||
|
}
|
||||||
|
|
||||||
public function testDuplicateSameProject()
|
public function testDuplicateSameProject()
|
||||||
{
|
{
|
||||||
$td = new TaskDuplication($this->container);
|
$td = new TaskDuplication($this->container);
|
||||||
|
|||||||
Reference in New Issue
Block a user