diff options
| author | Mark Felder <feld@FreeBSD.org> | 2020-06-30 15:09:03 -0500 | 
|---|---|---|
| committer | Mark Felder <feld@FreeBSD.org> | 2020-06-30 15:09:03 -0500 | 
| commit | 0883a706dc376fdfb7de9df1366803e87c8e7c98 (patch) | |
| tree | dc43f7b09dddd3300efd7b3ebbc0e82e60a978c5 /test/migration_helper | |
| parent | 954acdda2072cac343409b3d17d831b86ac6a18c (diff) | |
| parent | b9e6ad571ac5925431466d6e6b27c0b372bb7727 (diff) | |
| download | pleroma-0883a706dc376fdfb7de9df1366803e87c8e7c98.tar.gz pleroma-0883a706dc376fdfb7de9df1366803e87c8e7c98.zip  | |
Merge branch 'develop' into activation-meta
Diffstat (limited to 'test/migration_helper')
| -rw-r--r-- | test/migration_helper/notification_backfill_test.exs | 56 | 
1 files changed, 56 insertions, 0 deletions
diff --git a/test/migration_helper/notification_backfill_test.exs b/test/migration_helper/notification_backfill_test.exs new file mode 100644 index 000000000..2a62a2b00 --- /dev/null +++ b/test/migration_helper/notification_backfill_test.exs @@ -0,0 +1,56 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/> +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Pleroma.MigrationHelper.NotificationBackfillTest do +  use Pleroma.DataCase + +  alias Pleroma.Activity +  alias Pleroma.MigrationHelper.NotificationBackfill +  alias Pleroma.Notification +  alias Pleroma.Repo +  alias Pleroma.Web.CommonAPI + +  import Pleroma.Factory + +  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]) + +      NotificationBackfill.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 +end  | 
