From: David ‘Bombe’ Roden Date: Fri, 17 May 2019 18:19:44 +0000 (+0200) Subject: ✨ Use @TemplatePath in FreenetTemplatePage X-Git-Tag: v79^2~27 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=5b9d7d47f2e3ba720a3d5a5b94146904e5e10632;p=Sone.git ✨ Use @TemplatePath in FreenetTemplatePage --- diff --git a/src/main/kotlin/net/pterodactylus/sone/web/page/FreenetTemplatePage.kt b/src/main/kotlin/net/pterodactylus/sone/web/page/FreenetTemplatePage.kt index d93e7d1..792c0ba 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/page/FreenetTemplatePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/page/FreenetTemplatePage.kt @@ -34,8 +34,8 @@ import java.util.logging.Logger.* open class FreenetTemplatePage( private val path: String, private val templateContextFactory: TemplateContextFactory, - private val loaders: Loaders, - private val template: Template, + loaders: Loaders, + template: Template, private val invalidFormPasswordRedirectTarget: String ) : FreenetPage, LinkEnabledCallback { @@ -57,6 +57,8 @@ open class FreenetTemplatePage( override fun isEnabled(toadletContext: ToadletContext) = !isFullAccessOnly + private val template = templatePath?.let(loaders::loadTemplate) ?: template + override fun handleRequest(request: FreenetRequest, response: Response): Response { getRedirectTarget(request)?.let { redirectTarget -> return RedirectResponse(redirectTarget) } diff --git a/src/test/kotlin/net/pterodactylus/sone/web/page/FreenetTemplatePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/page/FreenetTemplatePageTest.kt index d992b30..def7410 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/page/FreenetTemplatePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/page/FreenetTemplatePageTest.kt @@ -8,11 +8,11 @@ import net.pterodactylus.util.web.Method.* import org.hamcrest.MatcherAssert.* import org.hamcrest.Matchers.* import org.junit.* -import org.mockito.ArgumentMatchers.* +import org.mockito.Mockito.* class FreenetTemplatePageTest { - private val templateContextFactory = mock() + private val templateContextFactory = deepMock() private val loaders = mock() private val template = mock