diff options
author | rinpatch <rinpatch@sdf.org> | 2019-12-08 13:07:05 +0000 |
---|---|---|
committer | rinpatch <rinpatch@sdf.org> | 2019-12-08 13:07:05 +0000 |
commit | 8404f8c8fbc4a60473df0977bc05e2587207d811 (patch) | |
tree | bff0ee7f5d0280722cfc49748103204d08394d6b /test/web/mastodon_api | |
parent | 29a3f70cba7bed31e6777832c4d2dc5c326b70c1 (diff) | |
parent | d4953474ac5546d771879c32d3a7ec40675a00a1 (diff) | |
download | pleroma-8404f8c8fbc4a60473df0977bc05e2587207d811.tar.gz |
Merge branch 'improve-move-notificaions-api' into 'develop'
Add `with_move` query param to the notifications API
See merge request pleroma/pleroma!2032
Diffstat (limited to 'test/web/mastodon_api')
-rw-r--r-- | test/web/mastodon_api/controllers/notification_controller_test.exs | 26 | ||||
-rw-r--r-- | test/web/mastodon_api/views/notification_view_test.exs | 6 |
2 files changed, 29 insertions, 3 deletions
diff --git a/test/web/mastodon_api/controllers/notification_controller_test.exs b/test/web/mastodon_api/controllers/notification_controller_test.exs index 00a85169e..f6d4ab9f0 100644 --- a/test/web/mastodon_api/controllers/notification_controller_test.exs +++ b/test/web/mastodon_api/controllers/notification_controller_test.exs @@ -341,6 +341,32 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do assert length(json_response(conn, 200)) == 1 end + test "see move notifications with `with_move` parameter", %{ + conn: conn + } do + old_user = insert(:user) + new_user = insert(:user, also_known_as: [old_user.ap_id]) + follower = insert(:user) + + User.follow(follower, old_user) + Pleroma.Web.ActivityPub.ActivityPub.move(old_user, new_user) + Pleroma.Tests.ObanHelpers.perform_all() + + conn = + conn + |> assign(:user, follower) + |> get("/api/v1/notifications") + + assert json_response(conn, 200) == [] + + conn = + build_conn() + |> assign(:user, follower) + |> get("/api/v1/notifications", %{"with_move" => "true"}) + + assert length(json_response(conn, 200)) == 1 + end + defp get_notification_id_by_activity(%{id: id}) do Notification |> Repo.get_by(activity_id: id) diff --git a/test/web/mastodon_api/views/notification_view_test.exs b/test/web/mastodon_api/views/notification_view_test.exs index 26e1afc85..ba1721e06 100644 --- a/test/web/mastodon_api/views/notification_view_test.exs +++ b/test/web/mastodon_api/views/notification_view_test.exs @@ -109,8 +109,8 @@ defmodule Pleroma.Web.MastodonAPI.NotificationViewTest do end test "Move 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]) + old_user = insert(:user) + new_user = insert(:user, also_known_as: [old_user.ap_id]) follower = insert(:user) User.follow(follower, old_user) @@ -120,7 +120,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationViewTest do old_user = refresh_record(old_user) new_user = refresh_record(new_user) - [notification] = Notification.for_user(follower) + [notification] = Notification.for_user(follower, %{with_move: true}) expected = %{ id: to_string(notification.id), |