Add test for the second page

This commit is contained in:
Maxim Filippov 2019-02-28 17:54:02 +03:00
parent 72b7a0797e
commit 70e82a3465
1 changed files with 36 additions and 18 deletions

View File

@ -331,26 +331,44 @@ test "/api/pleroma/admin/password_reset" do
assert conn.status == 200 assert conn.status == 200
end end
test "GET /api/pleroma/admin/users" do describe "GET /api/pleroma/admin/users" do
admin = insert(:user, info: %{is_admin: true}) test "renders users array for the first page" do
user = insert(:user) admin = insert(:user, info: %{is_admin: true})
user = insert(:user)
conn = conn =
build_conn() build_conn()
|> assign(:user, admin) |> assign(:user, admin)
|> get("/api/pleroma/admin/users?page=1") |> get("/api/pleroma/admin/users?page=1")
assert json_response(conn, 200) == %{ assert json_response(conn, 200) == %{
"count" => 1, "count" => 1,
"page_size" => 50, "page_size" => 50,
"users" => [ "users" => [
%{ %{
"deactivated" => user.info.deactivated, "deactivated" => user.info.deactivated,
"id" => user.id, "id" => user.id,
"nickname" => user.nickname "nickname" => user.nickname
} }
] ]
} }
end
test "renders empty array for the second page" do
admin = insert(:user, info: %{is_admin: true})
user = insert(:user)
conn =
build_conn()
|> assign(:user, admin)
|> get("/api/pleroma/admin/users?page=2")
assert json_response(conn, 200) == %{
"count" => 1,
"page_size" => 50,
"users" => []
}
end
end end
test "PATCH /api/pleroma/admin/users/:nickname/toggle_activation" do test "PATCH /api/pleroma/admin/users/:nickname/toggle_activation" do