Fixed bug preventing page revision restore
Added regression tests to cover. Fixes #341
This commit is contained in:
parent
668ce26269
commit
cc0ce7c630
2 changed files with 28 additions and 1 deletions
|
@ -1058,7 +1058,7 @@ class EntityRepo
|
|||
public function restorePageRevision(Page $page, Book $book, $revisionId)
|
||||
{
|
||||
$this->savePageRevision($page);
|
||||
$revision = $this->getById('page_revision', $revisionId);
|
||||
$revision = $page->revisions()->where('id', '=', $revisionId)->first();
|
||||
$page->fill($revision->toArray());
|
||||
$page->slug = $this->findSuitableSlug('page', $page->name, $page->id, $book->id);
|
||||
$page->text = strip_tags($page->html);
|
||||
|
|
|
@ -53,4 +53,31 @@ class PageContentTest extends TestCase
|
|||
$revisionView->assertSee('new content');
|
||||
}
|
||||
|
||||
public function test_page_revision_restore_updates_content()
|
||||
{
|
||||
$this->asEditor();
|
||||
|
||||
$entityRepo = $this->app[EntityRepo::class];
|
||||
$page = Page::first();
|
||||
$entityRepo->updatePage($page, $page->book_id, ['name' => 'updated page abc123', 'html' => '<p>new contente def456</p>', 'summary' => 'initial page revision testing']);
|
||||
$entityRepo->updatePage($page, $page->book_id, ['name' => 'updated page again', 'html' => '<p>new content</p>', 'summary' => 'page revision testing']);
|
||||
$page = Page::find($page->id);
|
||||
|
||||
|
||||
$pageView = $this->get($page->getUrl());
|
||||
$pageView->assertDontSee('abc123');
|
||||
$pageView->assertDontSee('def456');
|
||||
|
||||
$revToRestore = $page->revisions()->where('name', 'like', '%abc123')->first();
|
||||
$restoreReq = $this->get($page->getUrl() . '/revisions/' . $revToRestore->id . '/restore');
|
||||
$page = Page::find($page->id);
|
||||
|
||||
$restoreReq->assertStatus(302);
|
||||
$restoreReq->assertRedirect($page->getUrl());
|
||||
|
||||
$pageView = $this->get($page->getUrl());
|
||||
$pageView->assertSee('abc123');
|
||||
$pageView->assertSee('def456');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue