NOW MANAGED ON CODEBERG
Removed outdated translations and updated tests
Dan Brown621142a46ed3
diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.phpindex b03e34b9b..c68f5c1e1 100644--- a/database/factories/ModelFactory.php+++ b/database/factories/ModelFactory.php@@ -73,11 +73,11 @@ $factory->define(BookStack\Image::class, function ($faker) {});$factory->define(BookStack\Comment::class, function($faker) {- $text = $faker->paragraph(3);+ $text = $faker->paragraph(1);$html = '<p>' . $text. '</p>';return ['html' => $html,'text' => $text,- 'active' => 1+ 'parent_id' => null];});\ No newline at end of filediff --git a/resources/lang/de/entities.php b/resources/lang/de/entities.phpindex 910218a58..133cb9466 100644--- a/resources/lang/de/entities.php+++ b/resources/lang/de/entities.php@@ -235,25 +235,10 @@ return ['profile_not_created_books' => ':userName hat noch keine Bücher erstellt.',/**- * Comnents+ * Comments*/'comment' => 'Kommentar','comments' => 'Kommentare','comment_placeholder' => 'Geben Sie hier Ihre Kommentare ein (Markdown unterstützt)',- 'no_comments' => 'Keine Kommentare',- 'x_comments' => ':numComments Kommentare',- 'one_comment' => '1 Kommentar',- 'comments_loading' => 'Laden...','comment_save' => 'Kommentar speichern',- 'comment_reply' => 'Antworten',- 'comment_edit' => 'Bearbeiten',- 'comment_delete' => 'Löschen',- 'comment_cancel' => 'Abbrechen',- 'comment_created' => 'Kommentar hinzugefügt',- 'comment_updated' => 'Kommentar aktualisiert',- 'comment_deleted' => 'Kommentar gelöscht',- 'comment_updated_text' => 'Aktualisiert vor :updateDiff von',- 'comment_delete_confirm' => 'Der Inhalt des Kommentars wird entfernt. Bist du sicher, dass du diesen Kommentar löschen möchtest?',- 'comment_create' => 'Erstellt'-];diff --git a/resources/lang/en/entities.php b/resources/lang/en/entities.phpindex 4e1bb8526..ffd49f07d 100644--- a/resources/lang/en/entities.php+++ b/resources/lang/en/entities.php@@ -255,6 +255,4 @@ return ['comment_updated_success' => 'Comment updated','comment_delete_confirm' => 'Are you sure you want to delete this comment?','comment_in_reply_to' => 'In reply to :commentId',- 'comment_create' => 'Created'-];\ No newline at end of filediff --git a/resources/lang/es/entities.php b/resources/lang/es/entities.phpindex 2ca55a786..ba4ca955a 100644--- a/resources/lang/es/entities.php+++ b/resources/lang/es/entities.php@@ -220,20 +220,6 @@ return [*/'comment' => 'Comentario','comments' => 'Comentarios',- 'comment_placeholder' => 'Introduzca sus comentarios aquí, markdown supported ...',- 'no_comments' => 'No hay comentarios',- 'x_comments' => ':numComments Comentarios',- 'one_comment' => '1 Comentario',- 'comments_loading' => 'Cargando ...',+ 'comment_placeholder' => 'Introduzca sus comentarios aquí','comment_save' => 'Guardar comentario',- 'comment_reply' => 'Responder',- 'comment_edit' => 'Editar',- 'comment_delete' => 'Eliminar',- 'comment_cancel' => 'Cancelar',- 'comment_created' => 'Comentario añadido',- 'comment_updated' => 'Comentario actualizado',- 'comment_deleted' => 'Comentario eliminado',- 'comment_updated_text' => 'Actualizado hace :updateDiff por',- 'comment_delete_confirm' => 'Esto eliminará el contenido del comentario. ¿Estás seguro de que quieres eliminar este comentario?',- 'comment_create' => 'Creado'];diff --git a/resources/lang/fr/entities.php b/resources/lang/fr/entities.phpindex 0d89993e9..d4d9d2475 100644--- a/resources/lang/fr/entities.php+++ b/resources/lang/fr/entities.php@@ -219,20 +219,6 @@ return [*/'comment' => 'Commentaire','comments' => 'Commentaires',- 'comment_placeholder' => 'Entrez vos commentaires ici, merci supporté ...',- 'no_comments' => 'No Comments',- 'x_comments' => ':numComments Commentaires',- 'one_comment' => '1 Commentaire',- 'comments_loading' => 'Loading ...',+ 'comment_placeholder' => 'Entrez vos commentaires ici','comment_save' => 'Enregistrer le commentaire',- 'comment_reply' => 'Répondre',- 'comment_edit' => 'Modifier',- 'comment_delete' => 'Supprimer',- 'comment_cancel' => 'Annuler',- 'comment_created' => 'Commentaire ajouté',- 'comment_updated' => 'Commentaire mis à jour',- 'comment_deleted' => 'Commentaire supprimé',- 'comment_updated_text' => 'Mis à jour il y a :updateDiff par',- 'comment_delete_confirm' => 'Cela supprime le contenu du commentaire. Êtes-vous sûr de vouloir supprimer ce commentaire?',- 'comment_create' => 'Créé'];diff --git a/resources/lang/nl/entities.php b/resources/lang/nl/entities.phpindex 6df9e5dd9..a882294f1 100644--- a/resources/lang/nl/entities.php+++ b/resources/lang/nl/entities.php@@ -220,20 +220,6 @@ return [*/'comment' => 'Commentaar','comments' => 'Commentaren',- 'comment_placeholder' => 'Vul hier uw reacties in, markdown ondersteund ...',- 'no_comments' => 'No Comments',- 'x_comments' => ':numComments Opmerkingen',- 'one_comment' => '1 commentaar',- 'comments_loading' => 'Loading ...',+ 'comment_placeholder' => 'Vul hier uw reacties in','comment_save' => 'Opslaan opslaan',- 'comment_reply' => 'Antwoord',- 'comment_edit' => 'Bewerken',- 'comment_delete' => 'Verwijderen',- 'comment_cancel' => 'Annuleren',- 'comment_created' => 'Opmerking toegevoegd',- 'comment_updated' => 'Opmerking bijgewerkt',- 'comment_deleted' => 'Opmerking verwijderd',- 'comment_updated_text' => 'Bijgewerkt :updateDiff geleden door',- 'comment_delete_confirm' => 'Hiermee verwijdert u de inhoud van de reactie. Weet u zeker dat u deze reactie wilt verwijderen?',- 'comment_create' => 'Gemaakt'];\ No newline at end of filediff --git a/resources/lang/pt_BR/entities.php b/resources/lang/pt_BR/entities.phpindex e6b900fdd..bf0a8ac72 100644--- a/resources/lang/pt_BR/entities.php+++ b/resources/lang/pt_BR/entities.php@@ -220,20 +220,6 @@ return [*/'comentário' => 'Comentário','comentários' => 'Comentários',- 'comment_placeholder' => 'Digite seus comentários aqui, markdown suportado ...',- 'no_comments' => 'No Comments',- 'x_comments' => ':numComments Comentários',- 'one_comment' => '1 comentário',- 'comments_loading' => 'Carregando ....',+ 'comment_placeholder' => 'Digite seus comentários aqui','comment_save' => 'Salvar comentário',- 'comment_reply' => 'Responder',- 'comment_edit' => 'Editar',- 'comment_delete' => 'Excluir',- 'comment_cancel' => 'Cancelar',- 'comment_created' => 'Comentário adicionado',- 'comment_updated' => 'Comentário atualizado',- 'comment_deleted' => 'Comentário eliminado',- 'comment_updated_text' => 'Atualizado :updatedDiff atrás por',- 'comment_delete_confirm' => 'Isso removerá o conteúdo do comentário. Tem certeza de que deseja excluir esse comentário?',- 'comment_create' => 'Criada'];\ No newline at end of filediff --git a/resources/lang/sk/entities.php b/resources/lang/sk/entities.phpindex 7c8f34368..25a1af140 100644--- a/resources/lang/sk/entities.php+++ b/resources/lang/sk/entities.php@@ -229,20 +229,6 @@ return [*/'comment' => 'Komentár','comments' => 'Komentáre',- 'comment_placeholder' => 'Tu zadajte svoje pripomienky, podporované označenie ...',- 'no_comments' => 'No Comments',- 'x_comments' => ':numComments komentárov',- 'one_comment' => '1 komentár',- 'comments_loading' => 'Loading ..',+ 'comment_placeholder' => 'Tu zadajte svoje pripomienky','comment_save' => 'Uložiť komentár',- 'comment_reply' => 'Odpovedať',- 'comment_edit' => 'Upraviť',- 'comment_delete' => 'Odstrániť',- 'comment_cancel' => 'Zrušiť',- 'comment_created' => 'Pridaný komentár',- 'comment_updated' => 'Komentár aktualizovaný',- 'comment_deleted' => 'Komentár bol odstránený',- 'comment_updated_text' => 'Aktualizované pred :updateDiff',- 'comment_delete_confirm' => 'Tým sa odstráni obsah komentára. Naozaj chcete odstrániť tento komentár?',- 'comment_create' => 'Vytvorené'];diff --git a/tests/Entity/CommentTest.php b/tests/Entity/CommentTest.phpindex 86eb31213..04716c1c2 100644--- a/tests/Entity/CommentTest.php+++ b/tests/Entity/CommentTest.php@@ -3,109 +3,72 @@use BookStack\Page;use BookStack\Comment;-class CommentTest extends BrowserKitTest+class CommentTest extends TestCase{public function test_add_comment(){$this->asAdmin();- $page = $this->getPage();+ $page = Page::first();- $this->addComment($page);- }+ $comment = factory(Comment::class)->make(['parent_id' => 2]);+ $resp = $this->postJson("/ajax/page/$page->id/comment", $comment->getAttributes());- public function test_comment_reply()- {- $this->asAdmin();- $page = $this->getPage();+ $resp->assertStatus(200);+ $resp->assertSee($comment->text);- // add a normal comment- $createdComment = $this->addComment($page);+ $pageResp = $this->get($page->getUrl());+ $pageResp->assertSee($comment->text);- // reply to the added comment- $this->addComment($page, $createdComment['id']);+ $this->assertDatabaseHas('comments', [+ 'local_id' => 1,+ 'entity_id' => $page->id,+ 'entity_type' => 'BookStack\\Page',+ 'text' => $comment->text,+ 'parent_id' => 2+ ]);}public function test_comment_edit(){$this->asAdmin();- $page = $this->getPage();-- $createdComment = $this->addComment($page);- $comment = [- 'id' => $createdComment['id'],- 'page_id' => $createdComment['page_id']- ];- $this->updateComment($comment);+ $page = Page::first();++ $comment = factory(Comment::class)->make();+ $this->postJson("/ajax/page/$page->id/comment", $comment->getAttributes());++ $comment = $page->comments()->first();+ $newText = 'updated text content';+ $resp = $this->putJson("/ajax/comment/$comment->id", [+ 'text' => $newText,+ 'html' => '<p>'.$newText.'</p>',+ ]);++ $resp->assertStatus(200);+ $resp->assertSee($newText);+ $resp->assertDontSee($comment->text);++ $this->assertDatabaseHas('comments', [+ 'text' => $newText,+ 'entity_id' => $page->id+ ]);}public function test_comment_delete(){$this->asAdmin();- $page = $this->getPage();-- $createdComment = $this->addComment($page);-- $this->deleteComment($createdComment['id']);- }-- private function getPage() {$page = Page::first();- return $page;- }-- private function addComment($page, $parentCommentId = null) {$comment = factory(Comment::class)->make();- $url = "/ajax/page/$page->id/comment/";- $request = [- 'text' => $comment->text,- 'html' => $comment->html- ];- if (!empty($parentCommentId)) {- $request['parent_id'] = $parentCommentId;- }- $this->call('POST', $url, $request);-- $createdComment = $this->checkResponse();- return $createdComment;- }-- private function updateComment($comment) {- $tmpComment = factory(Comment::class)->make();- $url = '/ajax/page/' . $comment['page_id'] . '/comment/ ' . $comment['id'];- $request = [- 'text' => $tmpComment->text,- 'html' => $tmpComment->html- ];-- $this->call('PUT', $url, $request);-- $updatedComment = $this->checkResponse();- return $updatedComment;- }-- private function deleteComment($commentId) {- // Route::delete('/ajax/comment/{id}', 'CommentController@destroy');- $url = '/ajax/comment/' . $commentId;- $this->call('DELETE', $url);-- $deletedComment = $this->checkResponse();- return $deletedComment;- }-- private function checkResponse() {- $expectedResp = [- 'status' => 'success'- ];+ $this->postJson("/ajax/page/$page->id/comment", $comment->getAttributes());- $this->assertResponseOk();- $this->seeJsonContains($expectedResp);+ $comment = $page->comments()->first();- $resp = $this->decodeResponseJson();- $createdComment = $resp['comment'];- $this->assertArrayHasKey('id', $createdComment);+ $resp = $this->delete("/ajax/comment/$comment->id");+ $resp->assertStatus(200);- return $createdComment;+ $this->assertDatabaseMissing('comments', [+ 'id' => $comment->id+ ]);}}diff --git a/tests/Permissions/RolesTest.php b/tests/Permissions/RolesTest.phpindex f131ed885..bd9e01d45 100644--- a/tests/Permissions/RolesTest.php+++ b/tests/Permissions/RolesTest.php@@ -627,7 +627,7 @@ class RolesTest extends BrowserKitTest$page = Page::first();$viewerRole = \BookStack\Role::getRole('viewer');$viewer = $this->getViewer();- $this->actingAs($viewer)->visit($page->getUrl())->assertResponseOk();+ $this->actingAs($viewer)->visit($page->getUrl())->assertResponseStatus(200);$this->asAdmin()->put('/settings/roles/' . $viewerRole->id, ['display_name' => $viewerRole->display_name,@@ -667,97 +667,94 @@ class RolesTest extends BrowserKitTest$this->giveUserPermissions($this->user, ['comment-create-all']);$this->actingAs($this->user)->addComment($ownPage);- $this->assertResponseOk(200)->seeJsonContains(['status' => 'success']);+ $this->assertResponseStatus(200);}public function test_comment_update_own_permission () {$ownPage = $this->createEntityChainBelongingToUser($this->user)['page'];$this->giveUserPermissions($this->user, ['comment-create-all']);- $comment = $this->actingAs($this->user)->addComment($ownPage);+ $commentId = $this->actingAs($this->user)->addComment($ownPage);// no comment-update-own- $this->actingAs($this->user)->updateComment($ownPage, $comment['id']);+ $this->actingAs($this->user)->updateComment($commentId);$this->assertResponseStatus(403);$this->giveUserPermissions($this->user, ['comment-update-own']);// now has comment-update-own- $this->actingAs($this->user)->updateComment($ownPage, $comment['id']);- $this->assertResponseOk()->seeJsonContains(['status' => 'success']);+ $this->actingAs($this->user)->updateComment($commentId);+ $this->assertResponseStatus(200);}public function test_comment_update_all_permission () {$ownPage = $this->createEntityChainBelongingToUser($this->user)['page'];- $comment = $this->asAdmin()->addComment($ownPage);+ $commentId = $this->asAdmin()->addComment($ownPage);// no comment-update-all- $this->actingAs($this->user)->updateComment($ownPage, $comment['id']);+ $this->actingAs($this->user)->updateComment($commentId);$this->assertResponseStatus(403);$this->giveUserPermissions($this->user, ['comment-update-all']);// now has comment-update-all- $this->actingAs($this->user)->updateComment($ownPage, $comment['id']);- $this->assertResponseOk()->seeJsonContains(['status' => 'success']);+ $this->actingAs($this->user)->updateComment($commentId);+ $this->assertResponseStatus(200);}public function test_comment_delete_own_permission () {$ownPage = $this->createEntityChainBelongingToUser($this->user)['page'];$this->giveUserPermissions($this->user, ['comment-create-all']);- $comment = $this->actingAs($this->user)->addComment($ownPage);+ $commentId = $this->actingAs($this->user)->addComment($ownPage);// no comment-delete-own- $this->actingAs($this->user)->deleteComment($comment['id']);+ $this->actingAs($this->user)->deleteComment($commentId);$this->assertResponseStatus(403);$this->giveUserPermissions($this->user, ['comment-delete-own']);// now has comment-update-own- $this->actingAs($this->user)->deleteComment($comment['id']);- $this->assertResponseOk()->seeJsonContains(['status' => 'success']);+ $this->actingAs($this->user)->deleteComment($commentId);+ $this->assertResponseStatus(200);}public function test_comment_delete_all_permission () {$ownPage = $this->createEntityChainBelongingToUser($this->user)['page'];- $comment = $this->asAdmin()->addComment($ownPage);+ $commentId = $this->asAdmin()->addComment($ownPage);// no comment-delete-all- $this->actingAs($this->user)->deleteComment($comment['id']);+ $this->actingAs($this->user)->deleteComment($commentId);$this->assertResponseStatus(403);$this->giveUserPermissions($this->user, ['comment-delete-all']);// now has comment-delete-all- $this->actingAs($this->user)->deleteComment($comment['id']);- $this->assertResponseOk()->seeJsonContains(['status' => 'success']);+ $this->actingAs($this->user)->deleteComment($commentId);+ $this->assertResponseStatus(200);}private function addComment($page) {$comment = factory(\BookStack\Comment::class)->make();- $url = "/ajax/page/$page->id/comment/";+ $url = "/ajax/page/$page->id/comment";$request = ['text' => $comment->text,'html' => $comment->html];- $this->json('POST', $url, $request);- $resp = $this->decodeResponseJson();- if (isset($resp['comment'])) {- return $resp['comment'];- }- return null;+ $this->postJson($url, $request);+ $comment = $page->comments()->first();+ return $comment === null ? null : $comment->id;}- private function updateComment($page, $commentId) {+ private function updateComment($commentId) {$comment = factory(\BookStack\Comment::class)->make();- $url = "/ajax/page/$page->id/comment/$commentId";+ $url = "/ajax/comment/$commentId";$request = ['text' => $comment->text,'html' => $comment->html];- return $this->json('PUT', $url, $request);+ return $this->putJson($url, $request);}private function deleteComment($commentId) {