projects
/
Sone.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
e845284
)
Allow adding posts without specific ID
author
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Sat, 9 Sep 2017 16:52:17 +0000
(18:52 +0200)
committer
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Sat, 9 Sep 2017 16:52:17 +0000
(18:52 +0200)
src/test/kotlin/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPageTest.kt
patch
|
blob
|
history
src/test/kotlin/net/pterodactylus/sone/web/ajax/DeletePostAjaxPageTest.kt
patch
|
blob
|
history
src/test/kotlin/net/pterodactylus/sone/web/ajax/JsonPageTest.kt
patch
|
blob
|
history
diff --git
a/src/test/kotlin/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPageTest.kt
b/src/test/kotlin/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPageTest.kt
index
ff48460
..
6b110ae
100644
(file)
--- a/
src/test/kotlin/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPageTest.kt
+++ b/
src/test/kotlin/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPageTest.kt
@@
-23,7
+23,7
@@
class CreateReplyAjaxPageTest : JsonPageTest("createReply.ajax", pageSupplier =
@Test
fun `valid post ID results in created reply`() {
val post = mock<Post>()
@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")
val reply = mock<PostReply>().apply { whenever(id).thenReturn("reply-id") }
whenever(core.createReply(currentSone, post, "")).thenReturn(reply)
addRequestParameter("post", "post-id")
@@
-35,7
+35,7
@@
class CreateReplyAjaxPageTest : JsonPageTest("createReply.ajax", pageSupplier =
@Test
fun `text is filtered when creating reply`() {
val post = mock<Post>()
@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 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")
@@
-51,7
+51,7
@@
class CreateReplyAjaxPageTest : JsonPageTest("createReply.ajax", pageSupplier =
val sone = mock<Sone>().apply { whenever(id).thenReturn("local-sone") }
addLocalSone("local-sone", sone)
val post = mock<Post>()
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 reply = mock<PostReply>().apply { whenever(id).thenReturn("reply-id") }
whenever(core.createReply(sone, post, "Text")).thenReturn(reply)
addRequestParameter("post", "post-id")
diff --git
a/src/test/kotlin/net/pterodactylus/sone/web/ajax/DeletePostAjaxPageTest.kt
b/src/test/kotlin/net/pterodactylus/sone/web/ajax/DeletePostAjaxPageTest.kt
index
026b717
..
a57e66d
100644
(file)
--- a/
src/test/kotlin/net/pterodactylus/sone/web/ajax/DeletePostAjaxPageTest.kt
+++ b/
src/test/kotlin/net/pterodactylus/sone/web/ajax/DeletePostAjaxPageTest.kt
@@
-25,7
+25,7
@@
class DeletePostAjaxPageTest : JsonPageTest("deletePost.ajax", pageSupplier = ::
val post = mock<Post>()
val sone = mock<Sone>()
whenever(post.sone).thenReturn(sone)
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"))
addRequestParameter("post", "post-id")
assertThat(json.isSuccess, equalTo(false))
assertThat(json.error, equalTo("not-authorized"))
@@
-36,7
+36,7
@@
class DeletePostAjaxPageTest : JsonPageTest("deletePost.ajax", pageSupplier = ::
val post = mock<Post>()
val sone = mock<Sone>().apply { whenever(isLocal).thenReturn(true) }
whenever(post.sone).thenReturn(sone)
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)
addRequestParameter("post", "post-id")
assertThat(json.isSuccess, equalTo(true))
verify(core).deletePost(post)
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
58f7823
..
5656874
100644
(file)
--- a/
src/test/kotlin/net/pterodactylus/sone/web/ajax/JsonPageTest.kt
+++ b/
src/test/kotlin/net/pterodactylus/sone/web/ajax/JsonPageTest.kt
@@
-178,8
+178,8
@@
abstract class JsonPageTest(
localSones += id to sone
}
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) =
}
protected fun addNewPost(id: String, soneId: String, time: Long, recipientId: String? = null) =