]> BookStack Code Mirror - bookstack/commitdiff
Removed outdated translations and updated tests
authorDan Brown <redacted>
Sat, 9 Sep 2017 17:41:59 +0000 (18:41 +0100)
committerDan Brown <redacted>
Sat, 9 Sep 2017 17:41:59 +0000 (18:41 +0100)
database/factories/ModelFactory.php
resources/lang/de/entities.php
resources/lang/en/entities.php
resources/lang/es/entities.php
resources/lang/fr/entities.php
resources/lang/nl/entities.php
resources/lang/pt_BR/entities.php
resources/lang/sk/entities.php
tests/Entity/CommentTest.php
tests/Permissions/RolesTest.php

index b03e34b9b9c63d0a4f05edc687366582ff6ba894..c68f5c1e15ac8e4ce5ef86dc6e17be38a8a33928 100644 (file)
@@ -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 file
index 910218a58b5a041803e36453cd84d531d4512992..133cb94666259deaf97fefe6c5a022d72fa3c233 100644 (file)
@@ -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'
-
 ];
index 4e1bb8526fde3d64f873cc411517aaabb5058170..ffd49f07d0b3df115be64796dd97081c143f6af8 100644 (file)
@@ -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 file
index 2ca55a786ddbbdc8c77d2101f11e0667e4c06b76..ba4ca955ad95cead812755a2b529729cefbd45de 100644 (file)
@@ -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'
 ];
index 0d89993e9d8043ba4c6e3f9b9f6f5c24079ad5f6..d4d9d247575ae25eda3ed1ff2325268fe0f9e976 100644 (file)
@@ -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éé'
 ];
index 6df9e5dd992e74ff793b9e8578e962aec7bc8cd3..a882294f1493d13810f7dba96b32a5dcd306e1eb 100644 (file)
@@ -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 file
index e6b900fdd7c123888de453a3f8dab6879a3bcdf4..bf0a8ac7202ca0eb11bf1c867ab3dfb160240dc2 100644 (file)
@@ -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 file
index 7c8f343688cf9d7f8432b5e04808ee3e47351af0..25a1af140bad58d7539839fa2314f20c169ff071 100644 (file)
@@ -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é'
 ];
index 86eb31213204bc580201b6a4c6b2941c98782f63..04716c1c29d389cae945b493d0397d49a513dd96 100644 (file)
 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
+        ]);
     }
 }
index f131ed8857927263173cdddcf0b42546b427d06b..bd9e01d457b45f89a756b344622d52089fc73cf6 100644 (file)
@@ -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) {