X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;ds=sidebyside;f=test%2Fpleroma%2Fweb%2Fmastodon_api%2Fcontrollers%2Fnotification_controller_test.exs;h=6507835871f736694b756ad6bf0fc34c169c4e66;hb=dc9f66749c85352e0d7761ae2b9b8663a3aa3e3a;hp=2615912a8dac5fe06ca50ea0cbd1d4e19a78a7f0;hpb=b221d77a6da07c684bdbc63ddf4500e0d7ffeae8;p=akkoma diff --git a/test/pleroma/web/mastodon_api/controllers/notification_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/notification_controller_test.exs index 2615912a8..650783587 100644 --- a/test/pleroma/web/mastodon_api/controllers/notification_controller_test.exs +++ b/test/pleroma/web/mastodon_api/controllers/notification_controller_test.exs @@ -44,9 +44,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do |> get("/api/v1/notifications") expected_response = - "hi @#{user.nickname}" + "hi @#{user.nickname}" assert [%{"status" => %{"content" => response}} | _rest] = json_response_and_validate_schema(conn, 200) @@ -103,40 +101,40 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do assert [_] = result end - test "getting a single notification" do - %{user: user, conn: conn} = oauth_access(["read:notifications"]) - other_user = insert(:user) + test "excludes mentions from blockers when blockers_visible is false" do + clear_config([:activitypub, :blockers_visible], false) - {:ok, activity} = CommonAPI.post(other_user, %{status: "hi @#{user.nickname}"}) + %{user: user, conn: conn} = oauth_access(["read:notifications"]) + blocker = insert(:user) - {:ok, [notification]} = Notification.create_notifications(activity) + {:ok, _} = CommonAPI.block(blocker, user) + {:ok, activity} = CommonAPI.post(blocker, %{status: "hi @#{user.nickname}"}) - conn = get(conn, "/api/v1/notifications/#{notification.id}") + {:ok, [_notification]} = Notification.create_notifications(activity) - expected_response = - "hi @#{user.nickname}" + conn = + conn + |> assign(:user, user) + |> get("/api/v1/notifications") - assert %{"status" => %{"content" => response}} = json_response_and_validate_schema(conn, 200) - assert response == expected_response + assert [] == json_response_and_validate_schema(conn, 200) end - test "dismissing a single notification (deprecated endpoint)" do - %{user: user, conn: conn} = oauth_access(["write:notifications"]) + test "getting a single notification" do + %{user: user, conn: conn} = oauth_access(["read:notifications"]) other_user = insert(:user) {:ok, activity} = CommonAPI.post(other_user, %{status: "hi @#{user.nickname}"}) {:ok, [notification]} = Notification.create_notifications(activity) - conn = - conn - |> assign(:user, user) - |> put_req_header("content-type", "application/json") - |> post("/api/v1/notifications/dismiss", %{"id" => to_string(notification.id)}) + conn = get(conn, "/api/v1/notifications/#{notification.id}") - assert %{} = json_response_and_validate_schema(conn, 200) + expected_response = + "hi @#{user.nickname}" + + assert %{"status" => %{"content" => response}} = json_response_and_validate_schema(conn, 200) + assert response == expected_response end test "dismissing a single notification" do