X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fweb%2Fpleroma_api%2Fcontrollers%2Fmascot_controller_test.exs;h=e2ead6e154e85c77b215e069984f67a62c2d75e1;hb=9b6d89ff8c798079f4db18eb2b5c66a7426ecbc5;hp=40c33e609a64884f898c57016de9a7cc56905be9;hpb=ea4a462858c16d66228ab07db6c17e3cbd9114d1;p=akkoma
diff --git a/test/web/pleroma_api/controllers/mascot_controller_test.exs b/test/web/pleroma_api/controllers/mascot_controller_test.exs
index 40c33e609..e2ead6e15 100644
--- a/test/web/pleroma_api/controllers/mascot_controller_test.exs
+++ b/test/web/pleroma_api/controllers/mascot_controller_test.exs
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors
+# Copyright © 2017-2020 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.PleromaAPI.MascotControllerTest do
@@ -16,9 +16,12 @@ defmodule Pleroma.Web.PleromaAPI.MascotControllerTest do
filename: "sound.mp3"
}
- ret_conn = put(conn, "/api/v1/pleroma/mascot", %{"file" => non_image_file})
+ ret_conn =
+ conn
+ |> put_req_header("content-type", "multipart/form-data")
+ |> put("/api/v1/pleroma/mascot", %{"file" => non_image_file})
- assert json_response(ret_conn, 415)
+ assert json_response_and_validate_schema(ret_conn, 415)
file = %Plug.Upload{
content_type: "image/jpg",
@@ -26,9 +29,12 @@ defmodule Pleroma.Web.PleromaAPI.MascotControllerTest do
filename: "an_image.jpg"
}
- conn = put(conn, "/api/v1/pleroma/mascot", %{"file" => file})
+ conn =
+ conn
+ |> put_req_header("content-type", "multipart/form-data")
+ |> put("/api/v1/pleroma/mascot", %{"file" => file})
- assert %{"id" => _, "type" => image} = json_response(conn, 200)
+ assert %{"id" => _, "type" => image} = json_response_and_validate_schema(conn, 200)
end
test "mascot retrieving" do
@@ -37,7 +43,7 @@ defmodule Pleroma.Web.PleromaAPI.MascotControllerTest do
# When user hasn't set a mascot, we should just get pleroma tan back
ret_conn = get(conn, "/api/v1/pleroma/mascot")
- assert %{"url" => url} = json_response(ret_conn, 200)
+ assert %{"url" => url} = json_response_and_validate_schema(ret_conn, 200)
assert url =~ "pleroma-fox-tan-smol"
# When a user sets their mascot, we should get that back
@@ -47,9 +53,12 @@ defmodule Pleroma.Web.PleromaAPI.MascotControllerTest do
filename: "an_image.jpg"
}
- ret_conn = put(conn, "/api/v1/pleroma/mascot", %{"file" => file})
+ ret_conn =
+ conn
+ |> put_req_header("content-type", "multipart/form-data")
+ |> put("/api/v1/pleroma/mascot", %{"file" => file})
- assert json_response(ret_conn, 200)
+ assert json_response_and_validate_schema(ret_conn, 200)
user = User.get_cached_by_id(user.id)
@@ -58,7 +67,7 @@ defmodule Pleroma.Web.PleromaAPI.MascotControllerTest do
|> assign(:user, user)
|> get("/api/v1/pleroma/mascot")
- assert %{"url" => url, "type" => "image"} = json_response(conn, 200)
+ assert %{"url" => url, "type" => "image"} = json_response_and_validate_schema(conn, 200)
assert url =~ "an_image"
end
end