Skip to content

Commit

Permalink
notifications: Correctly stringify pmUsers to fix navigation to group…
Browse files Browse the repository at this point in the history
… PMs.

Navigation to a group PM on pressing a notification was broken
because pmUsers was incorrectly stringified in
GroupPm.getPmUsersString. Fix, and add a test for it.
  • Loading branch information
Chris Bobbe committed Feb 21, 2020
1 parent 16d8a67 commit ec1290f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ sealed class Recipient {
* pmUsers: the user IDs of all users in the conversation.
*/
data class GroupPm(val pmUsers: Set<Int>) : Recipient() {
fun getPmUsersString() = pmUsers.sorted().joinToString { toString() }
fun getPmUsersString() = pmUsers.sorted().joinToString { it.toString() }
}

/** A stream message. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,19 @@ class FcmMessageTest : FcmMessageTestBase() {
}
}

class RecipientTest : FcmMessageTestBase() {
@Test
fun `GroupPm#getPmUsersString gives the correct string`() {
expect.that(Recipient.GroupPm(pmUsers = setOf(123, 234, 345)).getPmUsersString())
.isEqualTo("123, 234, 345")
}
@Test
fun `GroupPm#getPmUsersString correctly reorders user ids`() {
expect.that(Recipient.GroupPm(pmUsers = setOf(234, 123, 23, 345)).getPmUsersString())
.isEqualTo("23, 123, 234, 345")
}
}

class MessageFcmMessageTest : FcmMessageTestBase() {
object Example {
val base = FcmMessageTestBase.Example.base.plus(sequenceOf(
Expand Down

0 comments on commit ec1290f

Please sign in to comment.