Change user.deactivated field to user.is_active
[akkoma] / test / pleroma / web / mastodon_api / controllers / account_controller_test.exs
index 3361c8669319313f1ee3a8586b6bf2be45a66648..d44b97cc74b0bdd2835a9afd2b48130b44120dab 100644 (file)
@@ -1,5 +1,5 @@
 # Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
@@ -126,7 +126,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
     end
 
     test "returns 404 for deactivated user", %{conn: conn} do
-      user = insert(:user, deactivated: true)
+      user = insert(:user, is_active: false)
 
       assert %{"error" => "Can't find user"} =
                conn
@@ -256,7 +256,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
     end
 
     test "deactivated user", %{conn: conn} do
-      user = insert(:user, deactivated: true)
+      user = insert(:user, is_active: false)
 
       assert %{"error" => "Can't find user"} ==
                conn
@@ -469,6 +469,21 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
                }
              ] = result
     end
+
+    test "paginates a user's statuses", %{user: user, conn: conn} do
+      {:ok, post_1} = CommonAPI.post(user, %{status: "first post"})
+      {:ok, post_2} = CommonAPI.post(user, %{status: "second post"})
+
+      response_1 = get(conn, "/api/v1/accounts/#{user.id}/statuses?limit=1")
+      assert [res] = json_response(response_1, 200)
+      assert res["id"] == post_2.id
+
+      response_2 = get(conn, "/api/v1/accounts/#{user.id}/statuses?limit=1&max_id=#{res["id"]}")
+      assert [res] = json_response(response_2, 200)
+      assert res["id"] == post_1.id
+
+      refute response_1 == response_2
+    end
   end
 
   defp local_and_remote_activities(%{local: local, remote: remote}) do
@@ -1411,8 +1426,6 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
                |> json_response_and_validate_schema(:ok)
 
       assert Token |> Repo.get_by(token: access_token) |> Repo.preload(:user) |> Map.get(:user)
-
-      Cachex.del(:used_captcha_cache, token)
     end
 
     test "returns 400 if any captcha field is not provided", %{conn: conn} do