Merge branch 'develop' of https://git.pleroma.social/pleroma/pleroma into develop
[akkoma] / test / notification_test.exs
index f2115a29efd266d2548a056ddc604b76af774c22..526f43fab7a53f1313bd602e2f0f392a6c70820c 100644 (file)
@@ -8,7 +8,6 @@ defmodule Pleroma.NotificationTest do
   import Pleroma.Factory
   import Mock
 
-  alias Pleroma.Activity
   alias Pleroma.FollowingRelationship
   alias Pleroma.Notification
   alias Pleroma.Repo
@@ -22,47 +21,6 @@ defmodule Pleroma.NotificationTest do
   alias Pleroma.Web.Push
   alias Pleroma.Web.Streamer
 
-  describe "fill_in_notification_types" do
-    test "it fills in missing notification types" do
-      user = insert(:user)
-      other_user = insert(:user)
-
-      {:ok, post} = CommonAPI.post(user, %{status: "yeah, @#{other_user.nickname}"})
-      {:ok, chat} = CommonAPI.post_chat_message(user, other_user, "yo")
-      {:ok, react} = CommonAPI.react_with_emoji(post.id, other_user, "☕")
-      {:ok, like} = CommonAPI.favorite(other_user, post.id)
-      {:ok, react_2} = CommonAPI.react_with_emoji(post.id, other_user, "☕")
-
-      data =
-        react_2.data
-        |> Map.put("type", "EmojiReaction")
-
-      {:ok, react_2} =
-        react_2
-        |> Activity.change(%{data: data})
-        |> Repo.update()
-
-      assert {5, nil} = Repo.update_all(Notification, set: [type: nil])
-
-      Notification.fill_in_notification_types()
-
-      assert %{type: "mention"} =
-               Repo.get_by(Notification, user_id: other_user.id, activity_id: post.id)
-
-      assert %{type: "favourite"} =
-               Repo.get_by(Notification, user_id: user.id, activity_id: like.id)
-
-      assert %{type: "pleroma:emoji_reaction"} =
-               Repo.get_by(Notification, user_id: user.id, activity_id: react.id)
-
-      assert %{type: "pleroma:emoji_reaction"} =
-               Repo.get_by(Notification, user_id: user.id, activity_id: react_2.id)
-
-      assert %{type: "pleroma:chat_mention"} =
-               Repo.get_by(Notification, user_id: other_user.id, activity_id: chat.id)
-    end
-  end
-
   describe "create_notifications" do
     test "creates a notification for an emoji reaction" do
       user = insert(:user)
@@ -348,6 +306,14 @@ defmodule Pleroma.NotificationTest do
 
       assert {:ok, []} == Notification.create_notifications(status)
     end
+
+    test "it disables notifications from people who are invisible" do
+      author = insert(:user, invisible: true)
+      user = insert(:user)
+
+      {:ok, status} = CommonAPI.post(author, %{status: "hey @#{user.nickname}"})
+      refute Notification.create_notification(status, user)
+    end
   end
 
   describe "follow / follow_request notifications" do