$resp = $this->get($book->getUrl('/create-chapter'));
$this->withHtml($resp)->assertElementContains('form[action="' . $book->getUrl('/create-chapter') . '"][method="POST"]', 'Save Chapter');
- $resp = $this->post($book->getUrl('/create-chapter'), $chapter->only('name', 'description'));
+ $resp = $this->post($book->getUrl('/create-chapter'), $chapter->only('name', 'description_html'));
$resp->assertRedirect($book->getUrl('/chapter/my-first-chapter'));
$resp = $this->get($book->getUrl('/chapter/my-first-chapter'));
$resp->assertSee($chapter->name);
- $resp->assertSee($chapter->description);
+ $resp->assertSee($chapter->description_html, false);
+ }
+
+ public function test_show_view_displays_description_if_no_description_html_set()
+ {
+ $chapter = $this->entities->chapter();
+ $chapter->description_html = '';
+ $chapter->description = "My great\ndescription\n\nwith newlines";
+ $chapter->save();
+
+ $resp = $this->asEditor()->get($chapter->getUrl());
+ $resp->assertSee("<p>My great<br>\ndescription<br>\n<br>\nwith newlines</p>", false);
}
public function test_delete()
// Hide pages to all non-admin roles
/** @var Page $page */
foreach ($chapter->pages as $page) {
- $this->entities->setPermissions($page, [], []);
+ $this->permissions->setEntityPermissions($page, [], []);
}
$this->asEditor()->post($chapter->getUrl('/copy'), [
public function test_copy_does_not_copy_pages_if_user_cant_page_create()
{
$chapter = $this->entities->chapterHasPages();
- $viewer = $this->getViewer();
- $this->giveUserPermissions($viewer, ['chapter-create-all']);
+ $viewer = $this->users->viewer();
+ $this->permissions->grantUserRolePermissions($viewer, ['chapter-create-all']);
// Lacking permission results in no copied pages
$this->actingAs($viewer)->post($chapter->getUrl('/copy'), [
$newChapter = Chapter::query()->where('name', '=', 'My copied chapter')->first();
$this->assertEquals(0, $newChapter->pages()->count());
- $this->giveUserPermissions($viewer, ['page-create-all']);
+ $this->permissions->grantUserRolePermissions($viewer, ['page-create-all']);
// Having permission rules in copied pages
$this->actingAs($viewer)->post($chapter->getUrl('/copy'), [
{
$chapter = $this->entities->chapter();
- $resp = $this->actingAs($this->getViewer())->get($chapter->getUrl());
+ $resp = $this->actingAs($this->users->viewer())->get($chapter->getUrl());
$this->withHtml($resp)->assertLinkNotExists($chapter->book->getUrl('sort'));
$resp = $this->asEditor()->get($chapter->getUrl());