From c7a324e45e46ac629a5a3da5c3458bc66d18938f Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 8 Feb 2020 11:48:49 +0100 Subject: [PATCH] =?utf8?q?=F0=9F=90=9B=20Don=E2=80=99t=20show=20notificati?= =?utf8?q?on=20for=20remote=20posts?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../pterodactylus/sone/web/notification/LocalPostHandler.kt | 6 +++--- .../sone/web/notification/LocalPostHandlerTest.kt | 10 ++++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/net/pterodactylus/sone/web/notification/LocalPostHandler.kt b/src/main/kotlin/net/pterodactylus/sone/web/notification/LocalPostHandler.kt index a5153ce..cd78dd0 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/notification/LocalPostHandler.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/notification/LocalPostHandler.kt @@ -33,9 +33,9 @@ class LocalPostHandler @Inject constructor(private val notificationManager: Noti fun newPostFound(newPostFoundEvent: NewPostFoundEvent) { newPostFoundEvent.post.onLocal { post -> notification.add(post) - } - if (!notificationManager.hasFirstStartNotification()) { - notificationManager.addNotification(notification) + if (!notificationManager.hasFirstStartNotification()) { + notificationManager.addNotification(notification) + } } } diff --git a/src/test/kotlin/net/pterodactylus/sone/web/notification/LocalPostHandlerTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/notification/LocalPostHandlerTest.kt index 45be33b..1d97ae8 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/notification/LocalPostHandlerTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/notification/LocalPostHandlerTest.kt @@ -54,15 +54,21 @@ class LocalPostHandlerTest { } @Test - fun `handler adds notification to manager`() { + fun `handler does not add notification to manager for post by remote sone`() { eventBus.post(NewPostFoundEvent(remotePost)) + assertThat(notificationManager.notifications, not(hasItem(notification))) + } + + @Test + fun `handler adds notification to manager`() { + eventBus.post(NewPostFoundEvent(localPost)) assertThat(notificationManager.notifications, contains(notification)) } @Test fun `handler does not add notification during first start`() { notificationManager.firstStart() - eventBus.post(NewPostFoundEvent(remotePost)) + eventBus.post(NewPostFoundEvent(localPost)) assertThat(notificationManager.notifications, not(hasItem(notification))) } -- 2.7.4