projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
AccountController: Remove unused `update_?` routes.
[akkoma]
/
test
/
web
/
pleroma_api
/
controllers
/
mascot_controller_test.exs
diff --git
a/test/web/pleroma_api/controllers/mascot_controller_test.exs
b/test/web/pleroma_api/controllers/mascot_controller_test.exs
index ae9539b04829728ee4e10edaa83ad34c274a7496..e2ead6e154e85c77b215e069984f67a62c2d75e1 100644
(file)
--- 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
# Pleroma: A lightweight social networking server
-# Copyright © 2017-20
19
Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-20
20
Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.PleromaAPI.MascotControllerTest do
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.PleromaAPI.MascotControllerTest do
@@
-7,10
+7,8
@@
defmodule Pleroma.Web.PleromaAPI.MascotControllerTest do
alias Pleroma.User
alias Pleroma.User
- import Pleroma.Factory
-
- test "mascot upload", %{conn: conn} do
- user = insert(:user)
+ test "mascot upload" do
+ %{conn: conn} = oauth_access(["write:accounts"])
non_image_file = %Plug.Upload{
content_type: "audio/mpeg",
non_image_file = %Plug.Upload{
content_type: "audio/mpeg",
@@
-18,12
+16,12
@@
defmodule Pleroma.Web.PleromaAPI.MascotControllerTest do
filename: "sound.mp3"
}
filename: "sound.mp3"
}
- conn =
+
ret_
conn =
conn
conn
- |>
assign(:user, user
)
+ |>
put_req_header("content-type", "multipart/form-data"
)
|> put("/api/v1/pleroma/mascot", %{"file" => non_image_file})
|> put("/api/v1/pleroma/mascot", %{"file" => non_image_file})
- assert json_response
(
conn, 415)
+ assert json_response
_and_validate_schema(ret_
conn, 415)
file = %Plug.Upload{
content_type: "image/jpg",
file = %Plug.Upload{
content_type: "image/jpg",
@@
-32,22
+30,20
@@
defmodule Pleroma.Web.PleromaAPI.MascotControllerTest do
}
conn =
}
conn =
- build_conn()
- |>
assign(:user, user
)
+ conn
+ |>
put_req_header("content-type", "multipart/form-data"
)
|> put("/api/v1/pleroma/mascot", %{"file" => file})
|> 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
end
- test "mascot retrieving", %{conn: conn} do
- user = insert(:user)
+ test "mascot retrieving" do
+ %{user: user, conn: conn} = oauth_access(["read:accounts", "write:accounts"])
+
# When user hasn't set a mascot, we should just get pleroma tan back
# When user hasn't set a mascot, we should just get pleroma tan back
- conn =
- conn
- |> assign(:user, user)
- |> get("/api/v1/pleroma/mascot")
+ ret_conn = get(conn, "/api/v1/pleroma/mascot")
- assert %{"url" => url} = json_response
(
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
assert url =~ "pleroma-fox-tan-smol"
# When a user sets their mascot, we should get that back
@@
-57,21
+53,21
@@
defmodule Pleroma.Web.PleromaAPI.MascotControllerTest do
filename: "an_image.jpg"
}
filename: "an_image.jpg"
}
- conn =
- build_conn()
- |>
assign(:user, user
)
+
ret_
conn =
+ conn
+ |>
put_req_header("content-type", "multipart/form-data"
)
|> put("/api/v1/pleroma/mascot", %{"file" => file})
|> put("/api/v1/pleroma/mascot", %{"file" => file})
- assert json_response
(
conn, 200)
+ assert json_response
_and_validate_schema(ret_
conn, 200)
user = User.get_cached_by_id(user.id)
conn =
user = User.get_cached_by_id(user.id)
conn =
- build_conn()
+ conn
|> assign(:user, user)
|> get("/api/v1/pleroma/mascot")
|> 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
assert url =~ "an_image"
end
end