]> BookStack Code Mirror - bookstack/commitdiff
Merge branch 'fix/#1662' of git://github.com/cw1998/BookStack into cw1998-fix/#1662
authorDan Brown <redacted>
Sun, 27 Oct 2019 16:44:41 +0000 (16:44 +0000)
committerDan Brown <redacted>
Sun, 27 Oct 2019 16:44:41 +0000 (16:44 +0000)
1  2 
tests/Entity/EntityTest.php

index b506da2aa62387126f3b5c69ffb678b0b6548fe6,c28ca8b3efd3b9ba7564265db77b10a9c5dbaebd..3d12ed7495943dcc75ef979d87d845a57c41ee47
@@@ -1,8 -1,10 +1,9 @@@
  <?php namespace Tests;
  
+ use BookStack\Entities\Bookshelf;
  use BookStack\Entities\Book;
  use BookStack\Entities\Chapter;
  use BookStack\Entities\Page;
 -use BookStack\Entities\Repos\EntityRepo;
  use BookStack\Auth\UserRepo;
  use BookStack\Entities\Repos\PageRepo;
  use Carbon\Carbon;
@@@ -191,7 -193,7 +192,7 @@@ class EntityTest extends BrowserKitTes
          $entities = $this->createEntityChainBelongingToUser($creator, $updater);
          $this->actingAs($creator);
          app(UserRepo::class)->destroy($creator);
 -        app(PageRepo::class)->savePageRevision($entities['page']);
 +        app(PageRepo::class)->update($entities['page'], ['html' => '<p>hello!</p>>']);
  
          $this->checkEntitiesViewable($entities);
      }
          $entities = $this->createEntityChainBelongingToUser($creator, $updater);
          $this->actingAs($updater);
          app(UserRepo::class)->destroy($updater);
 -        app(PageRepo::class)->savePageRevision($entities['page']);
 +        app(PageRepo::class)->update($entities['page'], ['html' => '<p>Hello there!</p>']);
  
          $this->checkEntitiesViewable($entities);
      }
  
      public function test_slug_multi_byte_lower_casing()
      {
 -        $entityRepo = app(EntityRepo::class);
 -        $book = $entityRepo->createFromInput('book', [
 +        $book = $this->newBook([
              'name' => 'КНИГА'
          ]);
  
  
      public function test_slug_format()
      {
 -        $entityRepo = app(EntityRepo::class);
 -        $book = $entityRepo->createFromInput('book', [
 +        $book = $this->newBook([
              'name' => 'PartA / PartB / PartC'
          ]);
  
          $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());
+     }
  }