X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=test%2Fweb%2Fmastodon_api%2Fmastodon_api_controller_test.exs;h=8443dc856ba420d592f4279e083e4b05fbb3bf62;hb=707cd9389c4cebd5318fbd43527d2d3578310149;hp=62677638dcd37147f2b7057729c52e1b34334d80;hpb=da4b670451fcc41b960aeb33adb9f0184ba599cf;p=akkoma diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs index 62677638d..8443dc856 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -10,6 +10,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do alias Pleroma.Web.{OStatus, CommonAPI} alias Pleroma.Web.ActivityPub.ActivityPub alias Pleroma.Web.MastodonAPI.FilterView + alias Ecto.Changeset import Pleroma.Factory import ExUnit.CaptureLog import Tesla.Mock @@ -386,7 +387,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do |> assign(:user, user) |> get("/api/v1/filters/#{filter.filter_id}") - assert response = json_response(conn, 200) + assert _response = json_response(conn, 200) end test "update a filter", %{conn: conn} do @@ -600,7 +601,9 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do |> get("/api/v1/notifications") expected_response = - "hi @#{user.nickname}" + "hi @#{user.nickname}" assert [%{"status" => %{"content" => response}} | _rest] = json_response(conn, 200) assert response == expected_response @@ -621,7 +624,9 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do |> get("/api/v1/notifications/#{notification.id}") expected_response = - "hi @#{user.nickname}" + "hi @#{user.nickname}" assert %{"status" => %{"content" => response}} = json_response(conn, 200) assert response == expected_response @@ -1357,7 +1362,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do assert [status] = json_response(first_conn, 200) assert status["id"] == to_string(activity.id) - assert [{"link", link_header}] = + assert [{"link", _link_header}] = Enum.filter(first_conn.resp_headers, fn element -> match?({"link", _}, element) end) # Honours query params @@ -1402,9 +1407,9 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do assert user = json_response(conn, 200) assert user["note"] == - "I drink #cofe with #cofe with @#{user2.nickname}" + }\" class=\"u-url mention\" href=\"#{user2.ap_id}\">@#{user2.nickname}" end test "updates the user's locking status", %{conn: conn} do @@ -1469,13 +1474,26 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do end test "get instance information", %{conn: conn} do - insert(:user, %{local: true}) user = insert(:user, %{local: true}) + + user2 = insert(:user, %{local: true}) + {:ok, _user2} = User.deactivate(user2, !user2.info.deactivated) + insert(:user, %{local: false, nickname: "u@peer1.com"}) insert(:user, %{local: false, nickname: "u@peer2.com"}) {:ok, _} = TwitterAPI.create_status(user, %{"status" => "cofe"}) + # Stats should count users with missing or nil `info.deactivated` value + user = Repo.get(User, user.id) + info_change = Changeset.change(user.info, %{deactivated: nil}) + + {:ok, _user} = + user + |> Changeset.change() + |> Changeset.put_embed(:info, info_change) + |> User.update_and_set_cache() + Pleroma.Stats.update_stats() conn = get(conn, "/api/v1/instance") @@ -1485,7 +1503,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do stats = result["stats"] assert stats - assert stats["user_count"] == 2 + assert stats["user_count"] == 1 assert stats["status_count"] == 1 assert stats["domain_count"] == 2 end @@ -1511,7 +1529,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do |> assign(:user, user) |> put("/api/web/settings", %{"data" => %{"programming" => "socks"}}) - assert result = json_response(conn, 200) + assert _result = json_response(conn, 200) user = User.get_cached_by_ap_id(user.ap_id) assert user.info.settings == %{"programming" => "socks"}