From 91129c80b0d3b9804e8ac9829a032548d666ae29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Thu, 20 Dec 2018 15:40:45 +0100 Subject: [PATCH 1/3] Fix duplicate call to delete MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- templates/part.navigation.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/part.navigation.php b/templates/part.navigation.php index 0e38b5305..5456cb1e9 100644 --- a/templates/part.navigation.php +++ b/templates/part.navigation.php @@ -25,10 +25,10 @@ t('Archive board')); ?> -
  • +
  • - t('Delete board')); ?> - + t('Delete board')); ?> +
  • From 944780f74b405507565ccd2c65b3ca5b90098c85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Thu, 14 Feb 2019 15:23:20 +0100 Subject: [PATCH 2/3] Only allow deletion for undeleted boards MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/Service/BoardService.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/Service/BoardService.php b/lib/Service/BoardService.php index d8997817a..dd11ad3e4 100644 --- a/lib/Service/BoardService.php +++ b/lib/Service/BoardService.php @@ -307,6 +307,9 @@ class BoardService { $this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_READ); $board = $this->find($id); + if ($board->getDeletedAt() > 0) { + throw new BadRequestException('This board has already been deleted'); + } $board->setDeletedAt(time()); $board = $this->boardMapper->update($board); $this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_BOARD, $board, ActivityManager::SUBJECT_BOARD_DELETE); From 3156f69717eef19db2a036fdaf947e04dcac31ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Tue, 5 Mar 2019 09:58:41 +0100 Subject: [PATCH 3/3] Fix tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- tests/unit/Service/BoardServiceTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/unit/Service/BoardServiceTest.php b/tests/unit/Service/BoardServiceTest.php index 203442b57..b5949bc81 100644 --- a/tests/unit/Service/BoardServiceTest.php +++ b/tests/unit/Service/BoardServiceTest.php @@ -204,6 +204,7 @@ class BoardServiceTest extends TestCase { public function testDelete() { $board = new Board(); $board->setOwner('admin'); + $board->setDeletedAt(0); $this->boardMapper->expects($this->once()) ->method('find') ->willReturn($board); @@ -213,7 +214,7 @@ class BoardServiceTest extends TestCase { 'admin' => 'admin', ]); $boardDeleted = clone $board; - $board->setDeletedAt(1); + $boardDeleted->setDeletedAt(1); $this->boardMapper->expects($this->once()) ->method('update') ->willReturn($boardDeleted);