tests: add tests for non-follows/non-followers settings
authorWilliam Pitcock <nenolod@dereferenced.org>
Sat, 25 May 2019 05:25:40 +0000 (05:25 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Sat, 25 May 2019 05:25:40 +0000 (05:25 +0000)
test/notification_test.exs

index 581db58a80296f51817ed2260a0b874440bd6eb8..b54414dcd1085ad390c01278ffe75ef6239aeb71 100644 (file)
@@ -113,6 +113,13 @@ defmodule Pleroma.NotificationTest do
       assert nil == Notification.create_notification(activity, followed)
     end
 
+    test "it disables notifications from non-followers" do
+      follower = insert(:user)
+      followed = insert(:user, info: %{notification_settings: %{"non_followers" => false}})
+      {:ok, activity} = CommonAPI.post(follower, %{"status" => "hey @#{followed.nickname}"})
+      assert nil == Notification.create_notification(activity, followed)
+    end
+
     test "it disables notifications from people the user follows" do
       follower = insert(:user, info: %{notification_settings: %{"follows" => false}})
       followed = insert(:user)
@@ -122,6 +129,13 @@ defmodule Pleroma.NotificationTest do
       assert nil == Notification.create_notification(activity, follower)
     end
 
+    test "it disables notifications from people the user does not follow" do
+      follower = insert(:user, info: %{notification_settings: %{"non_follows" => false}})
+      followed = insert(:user)
+      {:ok, activity} = CommonAPI.post(followed, %{"status" => "hey @#{follower.nickname}"})
+      assert nil == Notification.create_notification(activity, follower)
+    end
+
     test "it doesn't create a notification for user if he is the activity author" do
       activity = insert(:note_activity)
       author = User.get_cached_by_ap_id(activity.data["actor"])