mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-30 04:23:11 +03:00
Fixed restore revision save order, Added restore summary testing
Found during review of #2353, A revision would be stored before a restore which would result with a duplicate revision and the new summary would be assigned against the wrong content. This change saves the revison after restore and adds test to check the content and summary text.
This commit is contained in:
@ -66,6 +66,28 @@ class PageRevisionTest extends TestCase
|
||||
$pageView->assertSee('def456');
|
||||
}
|
||||
|
||||
public function test_page_revision_restore_sets_new_revision_with_summary()
|
||||
{
|
||||
$this->asEditor();
|
||||
|
||||
$pageRepo = app(PageRepo::class);
|
||||
$page = Page::first();
|
||||
$pageRepo->update($page, ['name' => 'updated page abc123', 'html' => '<p>new contente def456</p>', 'summary' => 'My first update']);
|
||||
$pageRepo->update($page, ['name' => 'updated page again', 'html' => '<p>new content</p>', 'summary' => '']);
|
||||
$page->refresh();
|
||||
|
||||
$revToRestore = $page->revisions()->where('name', 'like', '%abc123')->first();
|
||||
$this->put($page->getUrl() . '/revisions/' . $revToRestore->id . '/restore');
|
||||
$page->refresh();
|
||||
|
||||
$this->assertDatabaseHas('page_revisions', [
|
||||
'page_id' => $page->id,
|
||||
'text' => 'new contente def456',
|
||||
'type' => 'version',
|
||||
'summary' => "Restored from #{$revToRestore->id}; My first update",
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_page_revision_count_increments_on_update()
|
||||
{
|
||||
$page = Page::first();
|
||||
|
Reference in New Issue
Block a user