Add more tests for the rescue page
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 26 May 2017 17:31:41 +0000 (19:31 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 26 May 2017 17:31:41 +0000 (19:31 +0200)
src/test/kotlin/net/pterodactylus/sone/web/pages/RescuePageTest.kt

index 303a23c..300786a 100644 (file)
@@ -29,6 +29,22 @@ class RescuePageTest : WebPageTest() {
        }
 
        @Test
+       fun `page returns correct path`() {
+               assertThat(page.path, equalTo("rescue.html"))
+       }
+
+       @Test
+       fun `page requires login`() {
+               assertThat(page.requiresLogin(), equalTo(true))
+       }
+
+       @Test
+       fun `page returns correct title`() {
+               addTranslation("Page.Rescue.Title", "rescue page title")
+               assertThat(page.getPageTitle(freenetRequest), equalTo("rescue page title"))
+       }
+
+       @Test
        fun `get request sets rescuer in template context`() {
                verifyNoRedirect {
                        assertThat(templateContext["soneRescuer"], equalTo<Any>(soneRescuer))
@@ -62,4 +78,16 @@ class RescuePageTest : WebPageTest() {
                }
        }
 
+       @Test
+       fun `post request with negative edition will not set edition`() {
+               setMethod(POST)
+               addHttpRequestPart("fetch", "true")
+               addHttpRequestPart("edition", "-123")
+               verifyRedirect("rescue.html") {
+                       verify(soneRescuer, never()).setEdition(anyLong())
+                       verify(soneRescuer).startNextFetch()
+               }
+       }
+
+
 }