diff --git a/resources/views/books/create.blade.php b/resources/views/books/create.blade.php
index 6de81cd46..db3e90e51 100644
--- a/resources/views/books/create.blade.php
+++ b/resources/views/books/create.blade.php
@@ -28,7 +28,7 @@
{{ trans('entities.books_create') }}
diff --git a/resources/views/books/edit.blade.php b/resources/views/books/edit.blade.php
index 400fd6e81..ac11b58e2 100644
--- a/resources/views/books/edit.blade.php
+++ b/resources/views/books/edit.blade.php
@@ -18,7 +18,7 @@
{{ trans('entities.books_edit') }}
diff --git a/resources/views/books/form.blade.php b/resources/views/books/form.blade.php
index 8960b4135..a3235036e 100644
--- a/resources/views/books/form.blade.php
+++ b/resources/views/books/form.blade.php
@@ -31,11 +31,11 @@
- @include('components.tag-manager', ['entity' => isset($book)?$book:null, 'entityType' => 'chapter'])
+ @include('components.tag-manager', ['entity' => $book ?? null, 'entityType' => 'chapter'])
\ No newline at end of file
diff --git a/tests/Entity/EntityTest.php b/tests/Entity/EntityTest.php
index b506da2aa..3d12ed749 100644
--- a/tests/Entity/EntityTest.php
+++ b/tests/Entity/EntityTest.php
@@ -1,5 +1,6 @@
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());
+ }
+
}