Fixed error thrown when owner existed but the creator did not

Added test to cover.
For #2687
This commit is contained in:
Dan Brown 2021-04-20 21:03:44 +01:00
parent b3c47649b4
commit 20528a2442
2 changed files with 17 additions and 1 deletions

View File

@ -14,7 +14,7 @@
</div>
@endif
@if ($entity->ownedBy && $entity->ownedBy->id !== $entity->createdBy->id)
@if ($entity->ownedBy && $entity->owned_by !== $entity->created_by)
<div>
@icon('user'){!! trans('entities.meta_owned_name', [
'user' => "<a href='{$entity->ownedBy->getProfileUrl()}'>".e($entity->ownedBy->name). "</a>"

View File

@ -6,6 +6,22 @@ use Tests\TestCase;
class PageTest extends TestCase
{
public function test_page_view_when_creator_is_deleted_but_owner_exists()
{
$page = Page::query()->first();
$user = $this->getViewer();
$owner = $this->getEditor();
$page->created_by = $user->id;
$page->owned_by = $owner->id;
$page->save();
$user->delete();
$resp = $this->asAdmin()->get($page->getUrl());
$resp->assertStatus(200);
$resp->assertSeeText('Owned by ' . $owner->name);
}
public function test_page_creation_with_markdown_content()
{
$this->setSettings(['app-editor' => 'markdown']);