aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorWilliam Pitcock <nenolod@dereferenced.org>2018-11-06 23:02:55 +0000
committerWilliam Pitcock <nenolod@dereferenced.org>2018-11-06 23:02:55 +0000
commit50bf17465138cbd81117404231b22b3891cb67c3 (patch)
tree66cc9ccf49c3672a170f37c5197dc0564a4eb9bf /test
parentf16c2e0b1b524fa9fc6a3733dd47e1d82f199fc7 (diff)
downloadpleroma-50bf17465138cbd81117404231b22b3891cb67c3.tar.gz
tests: add tests for Notification.set_read_up_to()
Diffstat (limited to 'test')
-rw-r--r--test/notification_test.exs35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/notification_test.exs b/test/notification_test.exs
index d86b5c1ab..79290ac78 100644
--- a/test/notification_test.exs
+++ b/test/notification_test.exs
@@ -121,6 +121,41 @@ defmodule Pleroma.NotificationTest do
end
end
+ describe "set_read_up_to()" do
+ test "it sets all notifications as read up to a specified notification ID" do
+ user = insert(:user)
+ other_user = insert(:user)
+
+ {:ok, activity} =
+ TwitterAPI.create_status(user, %{
+ "status" => "hey @#{other_user.nickname}!"
+ })
+
+ {:ok, activity} =
+ TwitterAPI.create_status(user, %{
+ "status" => "hey again @#{other_user.nickname}!"
+ })
+
+ [n2, n1] = notifs = Notification.for_user(other_user)
+ assert length(notifs) == 2
+
+ assert n2.id > n1.id
+
+ {:ok, activity} =
+ TwitterAPI.create_status(user, %{
+ "status" => "hey yet again @#{other_user.nickname}!"
+ })
+
+ Notification.set_read_up_to(other_user, n2.id)
+
+ [n3, n2, n1] = notifs = Notification.for_user(other_user)
+
+ assert n1.seen == true
+ assert n2.seen == true
+ assert n3.seen == false
+ end
+ end
+
describe "notification lifecycle" do
test "liking an activity results in 1 notification, then 0 if the activity is deleted" do
user = insert(:user)