From: David ‘Bombe’ Roden Date: Sat, 18 Apr 2020 21:55:05 +0000 (+0200) Subject: 🚧 Add processing of strict-filtering option X-Git-Tag: v82^2~7 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=7a2061d9f8ae6508ffbbac724630ff5696592f0d;p=Sone.git 🚧 Add processing of strict-filtering option --- diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/OptionsPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/OptionsPage.kt index 412258d..9465a6a 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/OptionsPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/OptionsPage.kt @@ -40,9 +40,11 @@ class OptionsPage @Inject constructor(webInterface: WebInterface, loaders: Loade } val fullAccessRequired = "require-full-access" in soneRequest.parameters val fcpInterfaceActive = "fcp-interface-active" in soneRequest.parameters + val strictFiltering = "strict-filtering" in soneRequest.parameters soneRequest.core.preferences.newRequireFullAccess = fullAccessRequired soneRequest.core.preferences.newFcpInterfaceActive = fcpInterfaceActive + soneRequest.core.preferences.newStrictFiltering = strictFiltering val postsPerPage = soneRequest.parameters["posts-per-page"]?.toIntOrNull() val charactersPerPost = soneRequest.parameters["characters-per-post"]?.toIntOrNull() @@ -82,6 +84,7 @@ class OptionsPage @Inject constructor(webInterface: WebInterface, loaders: Loade templateContext["require-full-access"] = preferences.requireFullAccess templateContext["post-cut-off-length"] = preferences.postCutOffLength templateContext["posts-per-page"] = preferences.postsPerPage + templateContext["strict-filtering"] = preferences.strictFiltering } } diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/OptionsPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/OptionsPageTest.kt index d2929d9..d679e85 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/OptionsPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/OptionsPageTest.kt @@ -27,6 +27,7 @@ class OptionsPageTest : WebPageTest(::OptionsPage) { core.preferences.newRequireFullAccess = true core.preferences.newPostCutOffLength = 51 core.preferences.newPostsPerPage = 10 + core.preferences.newStrictFiltering = true } @Before @@ -76,6 +77,7 @@ class OptionsPageTest : WebPageTest(::OptionsPage) { assertThat(templateContext["require-full-access"], equalTo(true)) assertThat(templateContext["post-cut-off-length"], equalTo(51)) assertThat(templateContext["posts-per-page"], equalTo(10)) + assertThat(templateContext["strict-filtering"], equalTo(true)) } } @@ -308,6 +310,16 @@ class OptionsPageTest : WebPageTest(::OptionsPage) { } @Test + fun `strict filtering can be set to true`() { + verifyThatPreferencesCanBeSet("strict-filtering", "checked", true) { core.preferences.strictFiltering } + } + + @Test + fun `strict filtering can be set to false`() { + verifyThatPreferencesCanBeSet("strict-filtering", null, false) { core.preferences.strictFiltering } + } + + @Test fun `page can be created by dependency injection`() { assertThat(baseInjector.getInstance(), notNullValue()) }