From 1a99ad0764b71eff7cde42f9c13f384948977b18 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 9 Sep 2017 18:52:46 +0200 Subject: [PATCH] Allow adding replies without specific ID --- .../kotlin/net/pterodactylus/sone/web/ajax/DeleteReplyAjaxPageTest.kt | 4 ++-- src/test/kotlin/net/pterodactylus/sone/web/ajax/JsonPageTest.kt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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) { -- 2.7.4