From: David ‘Bombe’ Roden Date: Fri, 26 May 2017 17:31:41 +0000 (+0200) Subject: Add more tests for the rescue page X-Git-Tag: 0.9.7^2~191 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=06c501b8fef03b648fd71eb55abc92833ef2fb8c;p=Sone.git Add more tests for the rescue page --- diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/RescuePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/RescuePageTest.kt index 303a23c..300786a 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/RescuePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/RescuePageTest.kt @@ -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(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() + } + } + + }