From: David ‘Bombe’ Roden Date: Sat, 9 Sep 2017 16:52:46 +0000 (+0200) Subject: Allow adding replies without specific ID X-Git-Tag: 0.9.7^2~75 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=1a99ad0764b71eff7cde42f9c13f384948977b18;p=Sone.git Allow adding replies without specific ID --- diff --git a/src/test/kotlin/net/pterodactylus/sone/web/ajax/DeleteReplyAjaxPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/ajax/DeleteReplyAjaxPageTest.kt index 873d897..b4ad019 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/ajax/DeleteReplyAjaxPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/ajax/DeleteReplyAjaxPageTest.kt @@ -25,7 +25,7 @@ class DeleteReplyAjaxPageTest : JsonPageTest("deleteReply.ajax", pageSupplier = val reply = mock() val sone = mock() 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() 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) diff --git a/src/test/kotlin/net/pterodactylus/sone/web/ajax/JsonPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/ajax/JsonPageTest.kt index 5656874..60b2627 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/ajax/JsonPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/ajax/JsonPageTest.kt @@ -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) {