diff --git a/app/Repos/PageRepo.php b/app/Repos/PageRepo.php index a52cecad3..f7b48efdc 100644 --- a/app/Repos/PageRepo.php +++ b/app/Repos/PageRepo.php @@ -269,7 +269,7 @@ class PageRepo * @param Page $page * @return $this */ - private function saveRevision(Page $page) + public function saveRevision(Page $page) { $revision = $this->pageRevision->fill($page->toArray()); $revision->page_id = $page->id; diff --git a/resources/views/pages/revisions.blade.php b/resources/views/pages/revisions.blade.php index ae9e3562f..b7ec1f816 100644 --- a/resources/views/pages/revisions.blade.php +++ b/resources/views/pages/revisions.blade.php @@ -32,8 +32,12 @@ @foreach($page->revisions as $revision) {{$revision->name}} - {{$revision->createdBy->name}} - {{$revision->createdBy->name}} + + @if($revision->createdBy) + {{$revision->createdBy->name}} + @endif + + @if($revision->createdBy) {{$revision->createdBy->name}} @else Deleted User @endif {{$revision->created_at->format('jS F, Y H:i:s')}} ({{$revision->created_at->diffForHumans()}}) Preview diff --git a/tests/EntityTest.php b/tests/EntityTest.php index 02924c123..07553e7dc 100644 --- a/tests/EntityTest.php +++ b/tests/EntityTest.php @@ -173,26 +173,40 @@ class EntityTest extends TestCase public function testEntitiesViewableAfterCreatorDeletion() { + // Create required assets and revisions $creator = $this->getNewUser(); $updater = $this->getNewUser(); $entities = $this->createEntityChainBelongingToUser($creator, $updater); + $this->actingAs($creator); app('BookStack\Repos\UserRepo')->destroy($creator); + app('BookStack\Repos\PageRepo')->saveRevision($entities['page']); - $this->asAdmin()->visit($entities['book']->getUrl())->seeStatusCode(200) - ->visit($entities['chapter']->getUrl())->seeStatusCode(200) - ->visit($entities['page']->getUrl())->seeStatusCode(200); + $this->checkEntitiesViewable($entities); } public function testEntitiesViewableAfterUpdaterDeletion() { + // Create required assets and revisions $creator = $this->getNewUser(); $updater = $this->getNewUser(); $entities = $this->createEntityChainBelongingToUser($creator, $updater); + $this->actingAs($updater); app('BookStack\Repos\UserRepo')->destroy($updater); + app('BookStack\Repos\PageRepo')->saveRevision($entities['page']); - $this->asAdmin()->visit($entities['book']->getUrl())->seeStatusCode(200) + $this->checkEntitiesViewable($entities); + } + + private function checkEntitiesViewable($entities) + { + // Check pages and books are visible. + $this->asAdmin(); + $this->visit($entities['book']->getUrl())->seeStatusCode(200) ->visit($entities['chapter']->getUrl())->seeStatusCode(200) ->visit($entities['page']->getUrl())->seeStatusCode(200); + // Check revision listing shows no errors. + $this->visit($entities['page']->getUrl()) + ->click('Revisions')->seeStatusCode(200); }