1
0
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:
Dan Brown 2019-12-16 11:54:53 +00:00
parent f122bebae7
commit 017703ff1a
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9
2 changed files with 12 additions and 1 deletions

View File

@ -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());
}
/**

View File

@ -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());
}
}