- 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)
-
- assert {4, 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:chat_mention"} =
- Repo.get_by(Notification, user_id: other_user.id, activity_id: chat.id)
- end
- end
-