Removed outdated translations and updated tests

This commit is contained in:
Dan Brown 2017-09-09 18:41:59 +01:00
parent 0275d2ad58
commit 621142a46e
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9
10 changed files with 74 additions and 201 deletions

View File

@ -73,11 +73,11 @@ $factory->define(BookStack\Image::class, function ($faker) {
}); });
$factory->define(BookStack\Comment::class, function($faker) { $factory->define(BookStack\Comment::class, function($faker) {
$text = $faker->paragraph(3); $text = $faker->paragraph(1);
$html = '<p>' . $text. '</p>'; $html = '<p>' . $text. '</p>';
return [ return [
'html' => $html, 'html' => $html,
'text' => $text, 'text' => $text,
'active' => 1 'parent_id' => null
]; ];
}); });

View File

@ -235,25 +235,10 @@ return [
'profile_not_created_books' => ':userName hat noch keine Bücher erstellt.', 'profile_not_created_books' => ':userName hat noch keine Bücher erstellt.',
/** /**
* Comnents * Comments
*/ */
'comment' => 'Kommentar', 'comment' => 'Kommentar',
'comments' => 'Kommentare', 'comments' => 'Kommentare',
'comment_placeholder' => 'Geben Sie hier Ihre Kommentare ein (Markdown unterstützt)', '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_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'
]; ];

View File

@ -255,6 +255,4 @@ return [
'comment_updated_success' => 'Comment updated', 'comment_updated_success' => 'Comment updated',
'comment_delete_confirm' => 'Are you sure you want to delete this comment?', 'comment_delete_confirm' => 'Are you sure you want to delete this comment?',
'comment_in_reply_to' => 'In reply to :commentId', 'comment_in_reply_to' => 'In reply to :commentId',
'comment_create' => 'Created'
]; ];

View File

@ -220,20 +220,6 @@ return [
*/ */
'comment' => 'Comentario', 'comment' => 'Comentario',
'comments' => 'Comentarios', 'comments' => 'Comentarios',
'comment_placeholder' => 'Introduzca sus comentarios aquí, markdown supported ...', 'comment_placeholder' => 'Introduzca sus comentarios aquí',
'no_comments' => 'No hay comentarios',
'x_comments' => ':numComments Comentarios',
'one_comment' => '1 Comentario',
'comments_loading' => 'Cargando ...',
'comment_save' => 'Guardar comentario', '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'
]; ];

View File

@ -219,20 +219,6 @@ return [
*/ */
'comment' => 'Commentaire', 'comment' => 'Commentaire',
'comments' => 'Commentaires', 'comments' => 'Commentaires',
'comment_placeholder' => 'Entrez vos commentaires ici, merci supporté ...', 'comment_placeholder' => 'Entrez vos commentaires ici',
'no_comments' => 'No Comments',
'x_comments' => ':numComments Commentaires',
'one_comment' => '1 Commentaire',
'comments_loading' => 'Loading ...',
'comment_save' => 'Enregistrer le commentaire', '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éé'
]; ];

View File

@ -220,20 +220,6 @@ return [
*/ */
'comment' => 'Commentaar', 'comment' => 'Commentaar',
'comments' => 'Commentaren', 'comments' => 'Commentaren',
'comment_placeholder' => 'Vul hier uw reacties in, markdown ondersteund ...', 'comment_placeholder' => 'Vul hier uw reacties in',
'no_comments' => 'No Comments',
'x_comments' => ':numComments Opmerkingen',
'one_comment' => '1 commentaar',
'comments_loading' => 'Loading ...',
'comment_save' => 'Opslaan opslaan', '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'
]; ];

View File

@ -220,20 +220,6 @@ return [
*/ */
'comentário' => 'Comentário', 'comentário' => 'Comentário',
'comentários' => 'Comentários', 'comentários' => 'Comentários',
'comment_placeholder' => 'Digite seus comentários aqui, markdown suportado ...', 'comment_placeholder' => 'Digite seus comentários aqui',
'no_comments' => 'No Comments',
'x_comments' => ':numComments Comentários',
'one_comment' => '1 comentário',
'comments_loading' => 'Carregando ....',
'comment_save' => 'Salvar comentário', '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'
]; ];

View File

@ -229,20 +229,6 @@ return [
*/ */
'comment' => 'Komentár', 'comment' => 'Komentár',
'comments' => 'Komentáre', 'comments' => 'Komentáre',
'comment_placeholder' => 'Tu zadajte svoje pripomienky, podporované označenie ...', 'comment_placeholder' => 'Tu zadajte svoje pripomienky',
'no_comments' => 'No Comments',
'x_comments' => ':numComments komentárov',
'one_comment' => '1 komentár',
'comments_loading' => 'Loading ..',
'comment_save' => 'Uložiť komentár', '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é'
]; ];

View File

@ -3,109 +3,72 @@
use BookStack\Page; use BookStack\Page;
use BookStack\Comment; use BookStack\Comment;
class CommentTest extends BrowserKitTest class CommentTest extends TestCase
{ {
public function test_add_comment() public function test_add_comment()
{ {
$this->asAdmin(); $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() $resp->assertStatus(200);
{ $resp->assertSee($comment->text);
$this->asAdmin();
$page = $this->getPage();
// add a normal comment $pageResp = $this->get($page->getUrl());
$createdComment = $this->addComment($page); $pageResp->assertSee($comment->text);
// reply to the added comment $this->assertDatabaseHas('comments', [
$this->addComment($page, $createdComment['id']); 'local_id' => 1,
'entity_id' => $page->id,
'entity_type' => 'BookStack\\Page',
'text' => $comment->text,
'parent_id' => 2
]);
} }
public function test_comment_edit() public function test_comment_edit()
{ {
$this->asAdmin(); $this->asAdmin();
$page = $this->getPage(); $page = Page::first();
$createdComment = $this->addComment($page); $comment = factory(Comment::class)->make();
$comment = [ $this->postJson("/ajax/page/$page->id/comment", $comment->getAttributes());
'id' => $createdComment['id'],
'page_id' => $createdComment['page_id'] $comment = $page->comments()->first();
]; $newText = 'updated text content';
$this->updateComment($comment); $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() public function test_comment_delete()
{ {
$this->asAdmin(); $this->asAdmin();
$page = $this->getPage();
$createdComment = $this->addComment($page);
$this->deleteComment($createdComment['id']);
}
private function getPage() {
$page = Page::first(); $page = Page::first();
return $page;
}
private function addComment($page, $parentCommentId = null) {
$comment = factory(Comment::class)->make(); $comment = factory(Comment::class)->make();
$url = "/ajax/page/$page->id/comment/"; $this->postJson("/ajax/page/$page->id/comment", $comment->getAttributes());
$request = [
'text' => $comment->text,
'html' => $comment->html
];
if (!empty($parentCommentId)) {
$request['parent_id'] = $parentCommentId;
}
$this->call('POST', $url, $request);
$createdComment = $this->checkResponse(); $comment = $page->comments()->first();
return $createdComment;
}
private function updateComment($comment) { $resp = $this->delete("/ajax/comment/$comment->id");
$tmpComment = factory(Comment::class)->make(); $resp->assertStatus(200);
$url = '/ajax/page/' . $comment['page_id'] . '/comment/ ' . $comment['id'];
$request = [
'text' => $tmpComment->text,
'html' => $tmpComment->html
];
$this->call('PUT', $url, $request); $this->assertDatabaseMissing('comments', [
'id' => $comment->id
$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->assertResponseOk();
$this->seeJsonContains($expectedResp);
$resp = $this->decodeResponseJson();
$createdComment = $resp['comment'];
$this->assertArrayHasKey('id', $createdComment);
return $createdComment;
} }
} }

View File

@ -627,7 +627,7 @@ class RolesTest extends BrowserKitTest
$page = Page::first(); $page = Page::first();
$viewerRole = \BookStack\Role::getRole('viewer'); $viewerRole = \BookStack\Role::getRole('viewer');
$viewer = $this->getViewer(); $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, [ $this->asAdmin()->put('/settings/roles/' . $viewerRole->id, [
'display_name' => $viewerRole->display_name, 'display_name' => $viewerRole->display_name,
@ -667,97 +667,94 @@ class RolesTest extends BrowserKitTest
$this->giveUserPermissions($this->user, ['comment-create-all']); $this->giveUserPermissions($this->user, ['comment-create-all']);
$this->actingAs($this->user)->addComment($ownPage); $this->actingAs($this->user)->addComment($ownPage);
$this->assertResponseOk(200)->seeJsonContains(['status' => 'success']); $this->assertResponseStatus(200);
} }
public function test_comment_update_own_permission () { public function test_comment_update_own_permission () {
$ownPage = $this->createEntityChainBelongingToUser($this->user)['page']; $ownPage = $this->createEntityChainBelongingToUser($this->user)['page'];
$this->giveUserPermissions($this->user, ['comment-create-all']); $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 // no comment-update-own
$this->actingAs($this->user)->updateComment($ownPage, $comment['id']); $this->actingAs($this->user)->updateComment($commentId);
$this->assertResponseStatus(403); $this->assertResponseStatus(403);
$this->giveUserPermissions($this->user, ['comment-update-own']); $this->giveUserPermissions($this->user, ['comment-update-own']);
// now has comment-update-own // now has comment-update-own
$this->actingAs($this->user)->updateComment($ownPage, $comment['id']); $this->actingAs($this->user)->updateComment($commentId);
$this->assertResponseOk()->seeJsonContains(['status' => 'success']); $this->assertResponseStatus(200);
} }
public function test_comment_update_all_permission () { public function test_comment_update_all_permission () {
$ownPage = $this->createEntityChainBelongingToUser($this->user)['page']; $ownPage = $this->createEntityChainBelongingToUser($this->user)['page'];
$comment = $this->asAdmin()->addComment($ownPage); $commentId = $this->asAdmin()->addComment($ownPage);
// no comment-update-all // no comment-update-all
$this->actingAs($this->user)->updateComment($ownPage, $comment['id']); $this->actingAs($this->user)->updateComment($commentId);
$this->assertResponseStatus(403); $this->assertResponseStatus(403);
$this->giveUserPermissions($this->user, ['comment-update-all']); $this->giveUserPermissions($this->user, ['comment-update-all']);
// now has comment-update-all // now has comment-update-all
$this->actingAs($this->user)->updateComment($ownPage, $comment['id']); $this->actingAs($this->user)->updateComment($commentId);
$this->assertResponseOk()->seeJsonContains(['status' => 'success']); $this->assertResponseStatus(200);
} }
public function test_comment_delete_own_permission () { public function test_comment_delete_own_permission () {
$ownPage = $this->createEntityChainBelongingToUser($this->user)['page']; $ownPage = $this->createEntityChainBelongingToUser($this->user)['page'];
$this->giveUserPermissions($this->user, ['comment-create-all']); $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 // no comment-delete-own
$this->actingAs($this->user)->deleteComment($comment['id']); $this->actingAs($this->user)->deleteComment($commentId);
$this->assertResponseStatus(403); $this->assertResponseStatus(403);
$this->giveUserPermissions($this->user, ['comment-delete-own']); $this->giveUserPermissions($this->user, ['comment-delete-own']);
// now has comment-update-own // now has comment-update-own
$this->actingAs($this->user)->deleteComment($comment['id']); $this->actingAs($this->user)->deleteComment($commentId);
$this->assertResponseOk()->seeJsonContains(['status' => 'success']); $this->assertResponseStatus(200);
} }
public function test_comment_delete_all_permission () { public function test_comment_delete_all_permission () {
$ownPage = $this->createEntityChainBelongingToUser($this->user)['page']; $ownPage = $this->createEntityChainBelongingToUser($this->user)['page'];
$comment = $this->asAdmin()->addComment($ownPage); $commentId = $this->asAdmin()->addComment($ownPage);
// no comment-delete-all // no comment-delete-all
$this->actingAs($this->user)->deleteComment($comment['id']); $this->actingAs($this->user)->deleteComment($commentId);
$this->assertResponseStatus(403); $this->assertResponseStatus(403);
$this->giveUserPermissions($this->user, ['comment-delete-all']); $this->giveUserPermissions($this->user, ['comment-delete-all']);
// now has comment-delete-all // now has comment-delete-all
$this->actingAs($this->user)->deleteComment($comment['id']); $this->actingAs($this->user)->deleteComment($commentId);
$this->assertResponseOk()->seeJsonContains(['status' => 'success']); $this->assertResponseStatus(200);
} }
private function addComment($page) { private function addComment($page) {
$comment = factory(\BookStack\Comment::class)->make(); $comment = factory(\BookStack\Comment::class)->make();
$url = "/ajax/page/$page->id/comment/"; $url = "/ajax/page/$page->id/comment";
$request = [ $request = [
'text' => $comment->text, 'text' => $comment->text,
'html' => $comment->html 'html' => $comment->html
]; ];
$this->json('POST', $url, $request); $this->postJson($url, $request);
$resp = $this->decodeResponseJson(); $comment = $page->comments()->first();
if (isset($resp['comment'])) { return $comment === null ? null : $comment->id;
return $resp['comment'];
}
return null;
} }
private function updateComment($page, $commentId) { private function updateComment($commentId) {
$comment = factory(\BookStack\Comment::class)->make(); $comment = factory(\BookStack\Comment::class)->make();
$url = "/ajax/page/$page->id/comment/$commentId"; $url = "/ajax/comment/$commentId";
$request = [ $request = [
'text' => $comment->text, 'text' => $comment->text,
'html' => $comment->html 'html' => $comment->html
]; ];
return $this->json('PUT', $url, $request); return $this->putJson($url, $request);
} }
private function deleteComment($commentId) { private function deleteComment($commentId) {