mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-05-23 23:29:59 +08:00
Fix Book form (create) returning to the full books list on cancel
Fixes #1662 Added a small block of logic to determine the correct URL to attribute to the cancel button on a given page create form. If adding a book from a bookshelf, return to the bookshelf. If editing a book, return to the book. In all other cases, return to the full books list.
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
<?php namespace Tests;
|
||||
|
||||
use BookStack\Entities\Bookshelf;
|
||||
use BookStack\Entities\Book;
|
||||
use BookStack\Entities\Chapter;
|
||||
use BookStack\Entities\Page;
|
||||
@ -292,4 +293,29 @@ class EntityTest extends BrowserKitTest
|
||||
$this->assertEquals('parta-partb-partc', $book->slug);
|
||||
}
|
||||
|
||||
public function test_shelf_cancel_creation_returns_to_correct_place()
|
||||
{
|
||||
$shelf = Bookshelf::first();
|
||||
|
||||
// Cancel button from shelf goes back to shelf
|
||||
$this->asEditor()->visit($shelf->getUrl('/create-book'))
|
||||
->see('Cancel')
|
||||
->click('Cancel')
|
||||
->seePageIs($shelf->getUrl());
|
||||
|
||||
// Cancel button from books goes back to books
|
||||
$this->asEditor()->visit('/create-book')
|
||||
->see('Cancel')
|
||||
->click('Cancel')
|
||||
->seePageIs('/books');
|
||||
|
||||
// Cancel button from book edit goes back to book
|
||||
$book = Book::first();
|
||||
|
||||
$this->asEditor()->visit($book->getUrl('/edit'))
|
||||
->see('Cancel')
|
||||
->click('Cancel')
|
||||
->seePageIs($book->getUrl());
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user