mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
Adds tests and few fixes.
Signed-off-by: Abijeet <abijeetpatro@gmail.com>
This commit is contained in:
parent
25da4d9a8b
commit
54ca4487fa
@ -2,7 +2,6 @@
|
||||
|
||||
use Activity;
|
||||
use BookStack\Exceptions\NotFoundException;
|
||||
use BookStack\Exceptions\BadRequestException;
|
||||
use BookStack\Repos\EntityRepo;
|
||||
use BookStack\Repos\UserRepo;
|
||||
use BookStack\Services\ExportService;
|
||||
@ -480,7 +479,8 @@ class PageController extends Controller
|
||||
|
||||
// Check if its the latest revision, cannot delete latest revision.
|
||||
if (intval($current->id) === intval($revId)) {
|
||||
throw new BadRequestException("Cannot delete the current revision #{$revId}");
|
||||
session()->flash('error', trans('entities.revision_cannot_delete_latest'));
|
||||
return view('pages/revisions', ['page' => $page, 'book' => $page->book, 'current' => $page]);
|
||||
}
|
||||
|
||||
$revision->delete();
|
||||
|
@ -261,5 +261,6 @@ return [
|
||||
* Revision
|
||||
*/
|
||||
'revision_delete_confirm' => 'Sind Sie sicher, dass Sie diese Revision löschen wollen?',
|
||||
'revision_delete_success' => 'Revision gelöscht'
|
||||
'revision_delete_success' => 'Revision gelöscht',
|
||||
'revision_cannot_delete_latest' => 'Die letzte Version kann nicht gelöscht werden.'
|
||||
];
|
||||
|
@ -271,5 +271,6 @@ return [
|
||||
* Revision
|
||||
*/
|
||||
'revision_delete_confirm' => 'Are you sure you want to delete this revision?',
|
||||
'revision_delete_success' => 'Revision deleted'
|
||||
'revision_delete_success' => 'Revision deleted',
|
||||
'revision_cannot_delete_latest' => 'Cannot delete the latest revision.'
|
||||
];
|
@ -270,5 +270,6 @@ return [
|
||||
* Revision
|
||||
*/
|
||||
'revision_delete_confirm' => '¿Está seguro de que desea eliminar esta revisión?',
|
||||
'revision_delete_success' => 'Revisión eliminada'
|
||||
'revision_delete_success' => 'Revisión eliminada',
|
||||
'revision_cannot_delete_latest' => 'No se puede eliminar la última revisión.'
|
||||
];
|
||||
|
@ -270,5 +270,6 @@ return [
|
||||
* Revision
|
||||
*/
|
||||
'revision_delete_confirm' => 'Are you sure you want to delete this revision?',
|
||||
'revision_delete_success' => 'Revisión eliminada'
|
||||
'revision_delete_success' => 'Revisión eliminada',
|
||||
'revision_cannot_delete_latest' => 'No se puede eliminar la última revisión.'
|
||||
];
|
||||
|
@ -270,5 +270,6 @@ return [
|
||||
* Revision
|
||||
*/
|
||||
'revision_delete_confirm' => 'Êtes-vous sûr de vouloir supprimer cette révision?',
|
||||
'revision_delete_success' => 'Révision supprimée'
|
||||
'revision_delete_success' => 'Révision supprimée',
|
||||
'revision_cannot_delete_latest' => 'Impossible de supprimer la dernière révision.'
|
||||
];
|
@ -265,5 +265,6 @@ return [
|
||||
* Revision
|
||||
*/
|
||||
'revision_delete_confirm' => 'Sei sicuro di voler eliminare questa revisione?',
|
||||
'revision_delete_success' => 'Revisione cancellata'
|
||||
'revision_delete_success' => 'Revisione cancellata',
|
||||
'revision_cannot_delete_latest' => 'Impossibile eliminare l\'ultima revisione.'
|
||||
];
|
@ -262,5 +262,6 @@ return [
|
||||
* Revision
|
||||
*/
|
||||
'revision_delete_confirm' => 'このリビジョンを削除しますか?',
|
||||
'revision_delete_success' => 'リビジョンを削除しました'
|
||||
'revision_delete_success' => 'リビジョンを削除しました',
|
||||
'revision_cannot_delete_latest' => '最新のリビジョンを削除できません。'
|
||||
];
|
||||
|
@ -264,5 +264,6 @@ return [
|
||||
* Revision
|
||||
*/
|
||||
'revision_delete_confirm' => 'Weet u zeker dat u deze revisie wilt verwijderen?',
|
||||
'revision_delete_success' => 'Revisie verwijderd'
|
||||
'revision_delete_success' => 'Revisie verwijderd',
|
||||
'revision_cannot_delete_latest' => 'Kan de laatste revisie niet verwijderen.'
|
||||
];
|
||||
|
@ -262,5 +262,6 @@ return [
|
||||
* Revision
|
||||
*/
|
||||
'revision_delete_confirm' => 'Czy na pewno chcesz usunąć tę wersję?',
|
||||
'revision_delete_success' => 'Usunięto wersję'
|
||||
'revision_delete_success' => 'Usunięto wersję',
|
||||
'revision_cannot_delete_latest' => 'Nie można usunąć najnowszej wersji.'
|
||||
];
|
@ -263,5 +263,6 @@ return [
|
||||
* Revision
|
||||
*/
|
||||
'revision_delete_confirm' => 'Tem certeza de que deseja excluir esta revisão?',
|
||||
'revision_delete_success' => 'Revisão excluída'
|
||||
'revision_delete_success' => 'Revisão excluída',
|
||||
'revision_cannot_delete_latest' => 'Não é possível excluir a revisão mais recente.'
|
||||
];
|
@ -263,5 +263,6 @@ return [
|
||||
* Revision
|
||||
*/
|
||||
'revision_delete_confirm' => 'Вы действительно хотите удалить эту ревизию?',
|
||||
'revision_delete_success' => 'Редактирование удалено'
|
||||
'revision_delete_success' => 'Редактирование удалено',
|
||||
'revision_cannot_delete_latest' => 'Не удается удалить последнюю версию.'
|
||||
];
|
@ -237,5 +237,6 @@ return [
|
||||
* Revision
|
||||
*/
|
||||
'revision_delete_confirm' => 'Naozaj chcete túto revíziu odstrániť?',
|
||||
'revision_delete_success' => 'Revízia bola vymazaná'
|
||||
'revision_delete_success' => 'Revízia bola vymazaná',
|
||||
'revision_cannot_delete_latest' => 'Nie je možné vymazať poslednú revíziu.'
|
||||
];
|
||||
|
@ -270,5 +270,6 @@ return [
|
||||
* Revision
|
||||
*/
|
||||
'revision_delete_confirm' => 'Är du säker på att du vill radera den här versionen?',
|
||||
'revision_delete_success' => 'Revisionen raderad'
|
||||
'revision_delete_success' => 'Revisionen raderad',
|
||||
'revision_cannot_delete_latest' => 'Det går inte att ta bort den senaste versionen.'
|
||||
];
|
@ -262,5 +262,7 @@ return [
|
||||
/**
|
||||
* Revision
|
||||
*/
|
||||
'revision_delete_confirm' => '您确定要删除此修订版吗?'
|
||||
'revision_delete_confirm' => '您确定要删除此修订版吗?',
|
||||
'revision_delete_success' => '修订删除',
|
||||
'revision_cannot_delete_latest' => '无法删除最新版本。'
|
||||
];
|
||||
|
@ -264,5 +264,6 @@ return [
|
||||
* Revision
|
||||
*/
|
||||
'revision_delete_confirm' => '您確定要刪除此修訂版嗎?',
|
||||
'revision_delete_success' => '修訂刪除'
|
||||
'revision_delete_success' => '修訂刪除',
|
||||
'revision_cannot_delete_latest' => '無法刪除最新版本。'
|
||||
];
|
||||
|
@ -11,7 +11,6 @@ class PageRevisionTest extends TestCase
|
||||
{
|
||||
$page = Page::first();
|
||||
$startCount = $page->revision_count;
|
||||
|
||||
$resp = $this->asEditor()->put($page->getUrl(), ['name' => 'Updated page', 'html' => 'new page html', 'summary' => 'Update a']);
|
||||
$resp->assertStatus(302);
|
||||
|
||||
@ -29,4 +28,26 @@ class PageRevisionTest extends TestCase
|
||||
$pageView->assertSee('Revision #' . $page->revision_count);
|
||||
}
|
||||
|
||||
public function test_revision_deletion() {
|
||||
$page = Page::first();
|
||||
$this->asEditor()->put($page->getUrl(), ['name' => 'Updated page', 'html' => 'new page html', 'summary' => 'Update a']);
|
||||
$this->asEditor()->put($page->getUrl(), ['name' => 'Updated page', 'html' => 'new page html', 'summary' => 'Update a']);
|
||||
$page = Page::find($page->id);
|
||||
$beforeRevisionCount = $page->revisions->count();
|
||||
|
||||
// Delete the first revision
|
||||
$revision = $page->revisions->get(0);
|
||||
$resp = $this->asEditor()->delete($revision->getUrl('/delete/'));
|
||||
$resp->assertStatus(200);
|
||||
|
||||
$page = Page::find($page->id);
|
||||
$afterRevisionCount = $page->revisions->count();
|
||||
|
||||
$this->assertTrue($beforeRevisionCount === ($afterRevisionCount + 1));
|
||||
|
||||
// Try to delete the latest revision
|
||||
$revision = $page->revisions->get($page->revisions->count() - 1);
|
||||
$resp = $this->asEditor()->delete($revision->getUrl('/delete/'));
|
||||
$resp->assertSee('Cannot delete the latest revision');
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user