val soneRescuer = soneRequest.core.getSoneRescuer(currentSone)
templateContext["soneRescuer"] = soneRescuer
if (soneRequest.isPOST) {
- soneRequest.parameters["edition", 9]?.toIntOrNull()?.also {
- if (it > -1) {
- soneRescuer.setEdition(it.toLong())
- }
- }
if (soneRequest.parameters["fetch", 8] == "true") {
soneRescuer.startNextFetch()
}
<%/if>
<form action="rescue.html" method="post">
<input type="hidden" name="formPassword" value="<%formPassword|html>" />
- <label><%= Page.Rescue.Label.NextEdition|l10n|html></label>
- <input type="field" name="edition" value="<%soneRescuer.nextEdition>" />
- <button type="submit" name="fetch" value="true"><%= Page.Rescue.Button.Fetch|l10n|html></button>
+ <div>
+ <%= Page.Rescue.Label.NextEdition|l10n|html>: <%soneRescuer.nextEdition>
+ <button type="submit" name="fetch" value="true"><%= Page.Rescue.Button.Fetch|l10n|html></button>
+ </div>
</form>
<%else>
<%if soneRescuer.lastFetchSuccessful>
}
@Test
- fun `post request with fetch and invalid edition starts next fetch`() {
+ fun `post request with fetch starts next fetch`() {
setMethod(POST)
addHttpRequestPart("fetch", "true")
verifyRedirect("rescue.html") {
- verify(soneRescuer, never()).setEdition(anyLong())
- verify(soneRescuer).startNextFetch()
- }
- }
-
- @Test
- fun `post request with fetch and valid edition sets edition and starts next fetch`() {
- setMethod(POST)
- addHttpRequestPart("fetch", "true")
- addHttpRequestPart("edition", "123")
- verifyRedirect("rescue.html") {
- verify(soneRescuer).setEdition(123L)
- verify(soneRescuer).startNextFetch()
- }
- }
-
- @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()
}
}