mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-11-23 11:22:33 +01:00
Updated page delete to return to chapter if within one
- Added test to cover Closes #1715
This commit is contained in:
parent
f122bebae7
commit
017703ff1a
@ -304,11 +304,12 @@ class PageController extends Controller
|
||||
$this->checkOwnablePermission('page-delete', $page);
|
||||
|
||||
$book = $page->book;
|
||||
$parent = $page->chapter ?? $book;
|
||||
$this->pageRepo->destroy($page);
|
||||
Activity::addMessage('page_delete', $page->name, $book->id);
|
||||
|
||||
$this->showSuccessNotification(trans('entities.pages_delete_success'));
|
||||
return redirect($book->getUrl());
|
||||
return redirect($parent->getUrl());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -315,4 +315,14 @@ class EntityTest extends BrowserKitTest
|
||||
->seePageIs($book->getUrl());
|
||||
}
|
||||
|
||||
public function test_page_within_chapter_deletion_returns_to_chapter()
|
||||
{
|
||||
$chapter = Chapter::query()->first();
|
||||
$page = $chapter->pages()->first();
|
||||
|
||||
$this->asEditor()->visit($page->getUrl('/delete'))
|
||||
->submitForm('Confirm')
|
||||
->seePageIs($chapter->getUrl());
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user