@@ -33,23 +33,82 @@ public function test_slug_format()
3333 public function test_old_page_slugs_redirect_to_new_pages ()
3434 {
3535 $ page = $ this ->entities ->page ();
36+ $ pageUrl = $ page ->getUrl ();
3637
37- // Need to save twice since revisions are not generated in seeder.
38- $ this ->asAdmin ()->put ($ page ->getUrl (), [
39- 'name ' => 'super test ' ,
38+ $ this ->asAdmin ()->put ($ pageUrl , [
39+ 'name ' => 'super test page ' ,
4040 'html ' => '<p></p> ' ,
4141 ]);
4242
43- $ page ->refresh ();
43+ $ this ->get ($ pageUrl )
44+ ->assertRedirect ("/books/ {$ page ->book ->slug }/page/super-test-page " );
45+ }
46+
47+ public function test_old_shelf_slugs_redirect_to_new_shelf ()
48+ {
49+ $ shelf = $ this ->entities ->shelf ();
50+ $ shelfUrl = $ shelf ->getUrl ();
51+
52+ $ this ->asAdmin ()->put ($ shelf ->getUrl (), [
53+ 'name ' => 'super test shelf ' ,
54+ ]);
55+
56+ $ this ->get ($ shelfUrl )
57+ ->assertRedirect ("/shelves/super-test-shelf " );
58+ }
59+
60+ public function test_old_book_slugs_redirect_to_new_book ()
61+ {
62+ $ book = $ this ->entities ->book ();
63+ $ bookUrl = $ book ->getUrl ();
64+
65+ $ this ->asAdmin ()->put ($ book ->getUrl (), [
66+ 'name ' => 'super test book ' ,
67+ ]);
68+
69+ $ this ->get ($ bookUrl )
70+ ->assertRedirect ("/books/super-test-book " );
71+ }
72+
73+ public function test_old_chapter_slugs_redirect_to_new_chapter ()
74+ {
75+ $ chapter = $ this ->entities ->chapter ();
76+ $ chapterUrl = $ chapter ->getUrl ();
77+
78+ $ this ->asAdmin ()->put ($ chapter ->getUrl (), [
79+ 'name ' => 'super test chapter ' ,
80+ ]);
81+
82+ $ this ->get ($ chapterUrl )
83+ ->assertRedirect ("/books/ {$ chapter ->book ->slug }/chapter/super-test-chapter " );
84+ }
85+
86+ public function test_old_book_slugs_in_page_urls_redirect_to_current_page_url ()
87+ {
88+ $ page = $ this ->entities ->page ();
89+ $ book = $ page ->book ;
4490 $ pageUrl = $ page ->getUrl ();
4591
46- $ this ->put ($ pageUrl , [
47- 'name ' => 'super test page ' ,
48- 'html ' => '<p></p> ' ,
92+ $ this ->asAdmin ()->put ($ book ->getUrl (), [
93+ 'name ' => 'super test book ' ,
4994 ]);
5095
5196 $ this ->get ($ pageUrl )
52- ->assertRedirect ("/books/ {$ page ->book ->slug }/page/super-test-page " );
97+ ->assertRedirect ("/books/super-test-book/page/ {$ page ->slug }" );
98+ }
99+
100+ public function test_old_book_slugs_in_chapter_urls_redirect_to_current_chapter_url ()
101+ {
102+ $ chapter = $ this ->entities ->chapter ();
103+ $ book = $ chapter ->book ;
104+ $ chapterUrl = $ chapter ->getUrl ();
105+
106+ $ this ->asAdmin ()->put ($ book ->getUrl (), [
107+ 'name ' => 'super test book ' ,
108+ ]);
109+
110+ $ this ->get ($ chapterUrl )
111+ ->assertRedirect ("/books/super-test-book/chapter/ {$ chapter ->slug }" );
53112 }
54113
55114 public function test_slugs_recorded_in_history_on_page_update ()
0 commit comments