From 6c39fa20b191f985a2be704089c20acbcfe0035a Mon Sep 17 00:00:00 2001 From: Egor Kislitsyn Date: Tue, 17 Dec 2019 17:00:46 +0700 Subject: Add support for `account_id` param to filter notifications by the account --- .../controllers/notification_controller_test.exs | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'test') diff --git a/test/web/mastodon_api/controllers/notification_controller_test.exs b/test/web/mastodon_api/controllers/notification_controller_test.exs index 6635ea7a2..3458776ab 100644 --- a/test/web/mastodon_api/controllers/notification_controller_test.exs +++ b/test/web/mastodon_api/controllers/notification_controller_test.exs @@ -463,6 +463,29 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do assert length(json_response(conn, 200)) == 1 end + describe "from specified user" do + test "account_id", %{conn: conn} do + user = insert(:user) + %{id: account_id} = other_user1 = insert(:user) + other_user2 = insert(:user) + + {:ok, _activity} = CommonAPI.post(other_user1, %{"status" => "hi @#{user.nickname}"}) + {:ok, _activity} = CommonAPI.post(other_user2, %{"status" => "bye @#{user.nickname}"}) + + assert [%{"account" => %{"id" => ^account_id}}] = + conn + |> assign(:user, user) + |> get("/api/v1/notifications", %{account_id: account_id}) + |> json_response(200) + + assert [] = + conn + |> assign(:user, user) + |> get("/api/v1/notifications", %{account_id: "cofe"}) + |> json_response(200) + end + end + defp get_notification_id_by_activity(%{id: id}) do Notification |> Repo.get_by(activity_id: id) -- cgit v1.2.3 From 34d85f8a5473fe0f85e8a8e9e8f58e40b3964ba4 Mon Sep 17 00:00:00 2001 From: Egor Kislitsyn Date: Thu, 19 Dec 2019 20:45:44 +0700 Subject: Return 404 if account to filter notifications from is not found --- test/web/mastodon_api/controllers/notification_controller_test.exs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/web/mastodon_api/controllers/notification_controller_test.exs b/test/web/mastodon_api/controllers/notification_controller_test.exs index 3458776ab..24d0d49ed 100644 --- a/test/web/mastodon_api/controllers/notification_controller_test.exs +++ b/test/web/mastodon_api/controllers/notification_controller_test.exs @@ -478,11 +478,11 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do |> get("/api/v1/notifications", %{account_id: account_id}) |> json_response(200) - assert [] = + assert %{"error" => "Account is not found"} = conn |> assign(:user, user) |> get("/api/v1/notifications", %{account_id: "cofe"}) - |> json_response(200) + |> json_response(404) end end -- cgit v1.2.3 From 0d331f3d23963790b63f5b45b56adfe71651c7ee Mon Sep 17 00:00:00 2001 From: Alexander Strizhakov Date: Tue, 14 Jan 2020 15:49:52 +0300 Subject: compilation warnings fix --- test/web/twitter_api/util_controller_test.exs | 2 -- 1 file changed, 2 deletions(-) (limited to 'test') diff --git a/test/web/twitter_api/util_controller_test.exs b/test/web/twitter_api/util_controller_test.exs index 8418fd071..5d60c0d51 100644 --- a/test/web/twitter_api/util_controller_test.exs +++ b/test/web/twitter_api/util_controller_test.exs @@ -8,9 +8,7 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do alias Pleroma.Tests.ObanHelpers alias Pleroma.User - alias Pleroma.Web.CommonAPI - import ExUnit.CaptureLog import Pleroma.Factory import Mock -- cgit v1.2.3 From 023b7f605b5736b561f5b3a59de4d602933d7c71 Mon Sep 17 00:00:00 2001 From: Egor Kislitsyn Date: Wed, 15 Jan 2020 16:51:09 +0400 Subject: Fix notification controller test --- test/web/mastodon_api/controllers/notification_controller_test.exs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/web/mastodon_api/controllers/notification_controller_test.exs b/test/web/mastodon_api/controllers/notification_controller_test.exs index 38161982a..6f0606250 100644 --- a/test/web/mastodon_api/controllers/notification_controller_test.exs +++ b/test/web/mastodon_api/controllers/notification_controller_test.exs @@ -458,8 +458,9 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do end describe "from specified user" do - test "account_id", %{conn: conn} do - user = insert(:user) + test "account_id" do + %{user: user, conn: conn} = oauth_access(["read:notifications"]) + %{id: account_id} = other_user1 = insert(:user) other_user2 = insert(:user) -- cgit v1.2.3