1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-30 04:23:11 +03:00

Added ability to configure revision limit

This commit is contained in:
Dan Brown
2018-09-22 17:30:42 +01:00
parent 0931ff38e9
commit 3f58800ed1
4 changed files with 46 additions and 5 deletions

View File

@ -60,4 +60,34 @@ class PageRevisionTest extends TestCase
$afterRevisionCount = $page->revisions->count();
$this->assertTrue($beforeRevisionCount === $afterRevisionCount);
}
public function test_revision_limit_enforced()
{
config()->set('app.revision_limit', 2);
$page = Page::first();
$this->asEditor()->put($page->getUrl(), ['name' => 'Updated page', 'html' => 'new page html', 'summary' => 'Update a']);
$page = Page::find($page->id);
$this->asEditor()->put($page->getUrl(), ['name' => 'Updated page', 'html' => 'new page html', 'summary' => 'Update a']);
for ($i = 0; $i < 10; $i++) {
$this->asEditor()->put($page->getUrl(), ['name' => 'Updated page', 'html' => 'new page html', 'summary' => 'Update a']);
}
$revisionCount = $page->revisions()->count();
$this->assertEquals(2, $revisionCount);
}
public function test_false_revision_limit_allows_many_revisions()
{
config()->set('app.revision_limit', false);
$page = Page::first();
$this->asEditor()->put($page->getUrl(), ['name' => 'Updated page', 'html' => 'new page html', 'summary' => 'Update a']);
$page = Page::find($page->id);
$this->asEditor()->put($page->getUrl(), ['name' => 'Updated page', 'html' => 'new page html', 'summary' => 'Update a']);
for ($i = 0; $i < 10; $i++) {
$this->asEditor()->put($page->getUrl(), ['name' => 'Updated page', 'html' => 'new page html', 'summary' => 'Update a']);
}
$revisionCount = $page->revisions()->count();
$this->assertEquals(12, $revisionCount);
}
}