X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fnotification_test.exs;h=2200d03ea76da3843e279dd2fb7ad9c6a6093258;hb=e9993acdbbd1649bbcbf3fb36581b91145fe6055;hp=f8d42922322353a2d509dc8fc2c4c33313db186a;hpb=17c237ba808d4356bb1e202e459680563b79ef99;p=akkoma diff --git a/test/notification_test.exs b/test/notification_test.exs index f8d429223..2200d03ea 100644 --- a/test/notification_test.exs +++ b/test/notification_test.exs @@ -14,6 +14,8 @@ defmodule Pleroma.NotificationTest do alias Pleroma.Web.CommonAPI alias Pleroma.Web.Streamer + import ExUnit.CaptureLog + describe "create_notifications" do test "notifies someone when they are directly addressed" do user = insert(:user) @@ -431,7 +433,7 @@ defmodule Pleroma.NotificationTest do "status" => "hey @#{other_user.nickname}!" }) - {:ok, activity_two, _} = CommonAPI.favorite(activity_one.id, third_user) + {:ok, activity_two} = CommonAPI.favorite(third_user, activity_one.id) assert other_user not in Notification.get_notified_from_activity(activity_two) end @@ -461,7 +463,7 @@ defmodule Pleroma.NotificationTest do assert Enum.empty?(Notification.for_user(user)) - {:ok, _, _} = CommonAPI.favorite(activity.id, other_user) + {:ok, _} = CommonAPI.favorite(other_user, activity.id) assert length(Notification.for_user(user)) == 1 @@ -478,7 +480,7 @@ defmodule Pleroma.NotificationTest do assert Enum.empty?(Notification.for_user(user)) - {:ok, _, _} = CommonAPI.favorite(activity.id, other_user) + {:ok, _} = CommonAPI.favorite(other_user, activity.id) assert length(Notification.for_user(user)) == 1 @@ -533,7 +535,9 @@ defmodule Pleroma.NotificationTest do assert Enum.empty?(Notification.for_user(user)) - {:error, _} = CommonAPI.favorite(activity.id, other_user) + assert capture_log(fn -> + {:error, _} = CommonAPI.favorite(other_user, activity.id) + end) =~ "[error]" assert Enum.empty?(Notification.for_user(user)) end @@ -630,6 +634,35 @@ defmodule Pleroma.NotificationTest do assert Enum.empty?(Notification.for_user(local_user)) end + + test "move activity generates a notification" do + %{ap_id: old_ap_id} = old_user = insert(:user) + %{ap_id: new_ap_id} = new_user = insert(:user, also_known_as: [old_ap_id]) + follower = insert(:user) + other_follower = insert(:user, %{allow_following_move: false}) + + User.follow(follower, old_user) + User.follow(other_follower, old_user) + + Pleroma.Web.ActivityPub.ActivityPub.move(old_user, new_user) + ObanHelpers.perform_all() + + assert [ + %{ + activity: %{ + data: %{"type" => "Move", "actor" => ^old_ap_id, "target" => ^new_ap_id} + } + } + ] = Notification.for_user(follower) + + assert [ + %{ + activity: %{ + data: %{"type" => "Move", "actor" => ^old_ap_id, "target" => ^new_ap_id} + } + } + ] = Notification.for_user(other_follower) + end end describe "for_user" do