X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/f84bf8e883e8e5bd9a24b908e2f90a2742d36d19..refs/pull/2023/head:/tests/Entity/EntityTest.php diff --git a/tests/Entity/EntityTest.php b/tests/Entity/EntityTest.php index 6d71d6090..d7e4ec61c 100644 --- a/tests/Entity/EntityTest.php +++ b/tests/Entity/EntityTest.php @@ -7,6 +7,7 @@ use BookStack\Entities\Page; use BookStack\Auth\UserRepo; use BookStack\Entities\Repos\PageRepo; use Carbon\Carbon; +use Illuminate\Support\Facades\DB; use Tests\BrowserKitTest; class EntityTest extends BrowserKitTest @@ -326,4 +327,34 @@ class EntityTest extends BrowserKitTest ->seePageIs($chapter->getUrl()); } + public function test_page_delete_removes_entity_from_its_activity() + { + $page = Page::query()->first(); + + $this->asEditor()->put($page->getUrl(), [ + 'name' => 'My updated page', + 'html' => '

updated content

', + ]); + $page->refresh(); + + $this->seeInDatabase('activities', [ + 'entity_id' => $page->id, + 'entity_type' => $page->getMorphClass(), + ]); + + $resp = $this->delete($page->getUrl()); + $resp->assertResponseStatus(302); + + $this->dontSeeInDatabase('activities', [ + 'entity_id' => $page->id, + 'entity_type' => $page->getMorphClass(), + ]); + + $this->seeInDatabase('activities', [ + 'extra' => 'My updated page', + 'entity_id' => 0, + 'entity_type' => '', + ]); + } + }