🚧 Add processing of strict-filtering option
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 18 Apr 2020 21:55:05 +0000 (23:55 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 18 Apr 2020 21:55:05 +0000 (23:55 +0200)
src/main/kotlin/net/pterodactylus/sone/web/pages/OptionsPage.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/OptionsPageTest.kt

index 412258d..9465a6a 100644 (file)
@@ -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
                }
        }
 
index d2929d9..d679e85 100644 (file)
@@ -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<Any>(true))
                        assertThat(templateContext["post-cut-off-length"], equalTo<Any>(51))
                        assertThat(templateContext["posts-per-page"], equalTo<Any>(10))
+                       assertThat(templateContext["strict-filtering"], equalTo<Any>(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<OptionsPage>(), notNullValue())
        }