Add test for DI constructability of EditProfilePage
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 21 Jan 2018 08:00:04 +0000 (09:00 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 21 Jan 2018 08:00:07 +0000 (09:00 +0100)
src/main/kotlin/net/pterodactylus/sone/web/pages/EditProfilePage.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/EditProfilePageTest.kt

index 95c40c8..f1805cf 100644 (file)
@@ -8,11 +8,12 @@ import net.pterodactylus.sone.web.WebInterface
 import net.pterodactylus.sone.web.page.FreenetRequest
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
+import javax.inject.Inject
 
 /**
  * This page lets the user edit her profile.
  */
-class EditProfilePage(template: Template, webInterface: WebInterface) :
+class EditProfilePage @Inject constructor(template: Template, webInterface: WebInterface) :
                LoggedInPage("editProfile.html", template, "Page.EditProfile.Title", webInterface) {
 
        override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) {
index b4e6570..999a720 100644 (file)
@@ -2,8 +2,10 @@ package net.pterodactylus.sone.web.pages
 
 import net.pterodactylus.sone.data.Image
 import net.pterodactylus.sone.data.Profile
+import net.pterodactylus.sone.test.getInstance
 import net.pterodactylus.sone.test.mock
 import net.pterodactylus.sone.test.whenever
+import net.pterodactylus.sone.web.baseInjector
 import net.pterodactylus.util.web.Method.POST
 import org.hamcrest.MatcherAssert.assertThat
 import org.hamcrest.Matchers.contains
@@ -218,4 +220,9 @@ class EditProfilePageTest: WebPageTest(::EditProfilePage) {
                verifyRedirect("editProfileField.html?field=${firstField.id}")
        }
 
+       @Test
+       fun `page can be created by dependency injection`() {
+           assertThat(baseInjector.getInstance<EditProfilePage>(), notNullValue())
+       }
+
 }