Allow adding replies without specific ID
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 9 Sep 2017 16:52:46 +0000 (18:52 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 9 Sep 2017 16:52:46 +0000 (18:52 +0200)
src/test/kotlin/net/pterodactylus/sone/web/ajax/DeleteReplyAjaxPageTest.kt
src/test/kotlin/net/pterodactylus/sone/web/ajax/JsonPageTest.kt

index 873d897..b4ad019 100644 (file)
@@ -25,7 +25,7 @@ class DeleteReplyAjaxPageTest : JsonPageTest("deleteReply.ajax", pageSupplier =
                val reply = mock<PostReply>()
                val sone = mock<Sone>()
                whenever(reply.sone).thenReturn(sone)
-               addReply("reply-id", reply)
+               addReply(reply, "reply-id")
                addRequestParameter("reply", "reply-id")
                assertThat(json.isSuccess, equalTo(false))
                assertThat(json.error, equalTo("not-authorized"))
@@ -37,7 +37,7 @@ class DeleteReplyAjaxPageTest : JsonPageTest("deleteReply.ajax", pageSupplier =
                val sone = mock<Sone>()
                whenever(sone.isLocal).thenReturn(true)
                whenever(reply.sone).thenReturn(sone)
-               addReply("reply-id", reply)
+               addReply(reply, "reply-id")
                addRequestParameter("reply", "reply-id")
                assertThat(json.isSuccess, equalTo(true))
                verify(core).deleteReply(reply)
index 5656874..60b2627 100644 (file)
@@ -191,8 +191,8 @@ abstract class JsonPageTest(
                                whenever(this.recipientId).thenReturn(recipientId.asOptional())
                        }.also { newPosts[id] = it }
 
-       protected fun addReply(id: String, reply: PostReply) {
-               replies[id] = reply
+       protected fun addReply(reply: PostReply, id: String? = null) {
+               replies[id ?: reply.id] = reply
        }
 
        protected fun addNewReply(id: String, soneId: String, postId: String, postSoneId: String) {