@Test
fun `valid post ID results in created reply`() {
val post = mock<Post>()
- addPost("post-id", post)
+ addPost(post, "post-id")
val reply = mock<PostReply>().apply { whenever(id).thenReturn("reply-id") }
whenever(core.createReply(currentSone, post, "")).thenReturn(reply)
addRequestParameter("post", "post-id")
@Test
fun `text is filtered when creating reply`() {
val post = mock<Post>()
- addPost("post-id", post)
+ addPost(post, "post-id")
val reply = mock<PostReply>().apply { whenever(id).thenReturn("reply-id") }
whenever(core.createReply(currentSone, post, "Text with KSK@foo.bar link")).thenReturn(reply)
addRequestParameter("post", "post-id")
val sone = mock<Sone>().apply { whenever(id).thenReturn("local-sone") }
addLocalSone("local-sone", sone)
val post = mock<Post>()
- addPost("post-id", post)
+ addPost(post, "post-id")
val reply = mock<PostReply>().apply { whenever(id).thenReturn("reply-id") }
whenever(core.createReply(sone, post, "Text")).thenReturn(reply)
addRequestParameter("post", "post-id")
val post = mock<Post>()
val sone = mock<Sone>()
whenever(post.sone).thenReturn(sone)
- addPost("post-id", post)
+ addPost(post, "post-id")
addRequestParameter("post", "post-id")
assertThat(json.isSuccess, equalTo(false))
assertThat(json.error, equalTo("not-authorized"))
val post = mock<Post>()
val sone = mock<Sone>().apply { whenever(isLocal).thenReturn(true) }
whenever(post.sone).thenReturn(sone)
- addPost("post-id", post)
+ addPost(post, "post-id")
addRequestParameter("post", "post-id")
assertThat(json.isSuccess, equalTo(true))
verify(core).deletePost(post)
localSones += id to sone
}
- protected fun addPost(id: String, post: Post) {
- posts[id] = post
+ protected fun addPost(post: Post, id: String? = null) {
+ posts[id ?: post.id] = post
}
protected fun addNewPost(id: String, soneId: String, time: Long, recipientId: String? = null) =