Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/Service/BoardService.php
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,7 @@ public function clone(
$newStack->setOrder($stack->getOrder());
}
$newStack->setBoardId($newBoard->getId());
$newStack->setIsDoneColumn($stack->getIsDoneColumn());
$this->stackMapper->insert($newStack);
}

Expand Down
1 change: 1 addition & 0 deletions lib/Service/Importer/Systems/DeckJsonService.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ public function getStacks(): array {
$stack->setBoardId($this->getImportService()->getBoard()->getId());
$stack->setOrder($source->order);
$stack->setLastModified($source->lastModified);
$stack->setIsDoneColumn($source->isDoneColumn ?? false);
$return[$source->id] = $stack;
}

Expand Down
38 changes: 38 additions & 0 deletions tests/unit/Service/BoardServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
use OCA\Deck\Db\LabelMapper;
use OCA\Deck\Db\Session;
use OCA\Deck\Db\SessionMapper;
use OCA\Deck\Db\Stack;
use OCA\Deck\Db\StackMapper;
use OCA\Deck\Db\User;
use OCA\Deck\Event\AclCreatedEvent;
Expand Down Expand Up @@ -736,6 +737,43 @@ public function testUpdateArchivedLogsCriticalAction(): void {
$this->assertSame(['boardId' => 123], $auditEvents[0]->getParameters());
}

public function testCloneKeepsDoneColumn(): void {
$board = new Board();
$board->setId(1);
$board->setOwner('admin');
$board->setTitle('Board');
$board->setColor('ffffff');
$doneStack = new Stack();
$doneStack->setTitle('Done');
$doneStack->setOrder(1);
$doneStack->setIsDoneColumn(true);
$openStack = new Stack();
$openStack->setTitle('Open');
$openStack->setOrder(0);
$this->permissionService->method('canCreate')->willReturn(true);
$this->permissionService->method('findUsers')->willReturn(['admin' => 'admin']);
$this->boardMapper->method('find')->willReturn($board);
$this->boardMapper->method('insert')
->willReturnCallback(static function (Board $newBoard): Board {
$newBoard->setId(2);
return $newBoard;
});
$this->aclMapper->method('findAll')->willReturn([]);
$this->labelMapper->method('findAll')->willReturn([]);
$this->stackMapper->method('findAll')->willReturn([$doneStack, $openStack]);
$this->sessionMapper->method('findAllActive')->willReturn([]);
$inserted = [];
$this->stackMapper->method('insert')
->willReturnCallback(static function (Stack $stack) use (&$inserted): Stack {
$inserted[$stack->getTitle()] = $stack->getIsDoneColumn();
return $stack;
});

$this->service->clone(1, 'admin');

$this->assertSame(['Done' => true, 'Open' => false], $inserted);
}

public function testCloneLogsCriticalAction(): void {
$board = new Board();
$board->setId(1);
Expand Down
15 changes: 15 additions & 0 deletions tests/unit/Service/Importer/Systems/DeckJsonServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,21 @@ public function testGetCards() {
$this->assertEquals('# Test description' . "\n\n" . 'Hello world', $card119->getDescription());
}

public function testGetStacksKeepsDoneColumn(): void {
$importService = $this->setUpImportService();
$importService->getData()->stacks = [
(object)['id' => 1, 'title' => 'Done', 'order' => 0, 'lastModified' => 0, 'isDoneColumn' => true],
(object)['id' => 2, 'title' => 'Open', 'order' => 1, 'lastModified' => 0, 'isDoneColumn' => false],
(object)['id' => 3, 'title' => 'Old export', 'order' => 2, 'lastModified' => 0],
];

$stacks = $this->service->getStacks();

$this->assertTrue($stacks[1]->getIsDoneColumn());
$this->assertFalse($stacks[2]->getIsDoneColumn());
$this->assertFalse($stacks[3]->getIsDoneColumn());
}

private function setUpImportService(): BoardImportService {
$importService = Server::get(BoardImportService::class);

Expand Down