projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'patch-1' into 'develop'
[akkoma]
/
test
/
web
/
mastodon_api
/
controllers
/
media_controller_test.exs
diff --git
a/test/web/mastodon_api/controllers/media_controller_test.exs
b/test/web/mastodon_api/controllers/media_controller_test.exs
index 06c6a1cb31e847e0797e886fdac7834f9930e935..203fa73b029e1d4216900761f297c9848037834f 100644
(file)
--- a/
test/web/mastodon_api/controllers/media_controller_test.exs
+++ b/
test/web/mastodon_api/controllers/media_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.MastodonAPI.MediaControllerTest do
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.MastodonAPI.MediaControllerTest do
@@
-9,23
+9,17
@@
defmodule Pleroma.Web.MastodonAPI.MediaControllerTest do
alias Pleroma.User
alias Pleroma.Web.ActivityPub.ActivityPub
alias Pleroma.User
alias Pleroma.Web.ActivityPub.ActivityPub
- import Pleroma.Factory
+ setup do: oauth_access(["write:media"])
describe "media upload" do
setup do
describe "media upload" do
setup do
- user = insert(:user)
-
- conn =
- build_conn()
- |> assign(:user, user)
-
image = %Plug.Upload{
content_type: "image/jpg",
path: Path.absname("test/fixtures/image.jpg"),
filename: "an_image.jpg"
}
image = %Plug.Upload{
content_type: "image/jpg",
path: Path.absname("test/fixtures/image.jpg"),
filename: "an_image.jpg"
}
- [
conn: conn,
image: image]
+ [image: image]
end
clear_config([:media_proxy])
end
clear_config([:media_proxy])
@@
-49,9
+43,7
@@
defmodule Pleroma.Web.MastodonAPI.MediaControllerTest do
end
describe "PUT /api/v1/media/:id" do
end
describe "PUT /api/v1/media/:id" do
- setup do
- actor = insert(:user)
-
+ setup %{user: actor} do
file = %Plug.Upload{
content_type: "image/jpg",
path: Path.absname("test/fixtures/image.jpg"),
file = %Plug.Upload{
content_type: "image/jpg",
path: Path.absname("test/fixtures/image.jpg"),
@@
-65,13
+57,12
@@
defmodule Pleroma.Web.MastodonAPI.MediaControllerTest do
description: "test-m"
)
description: "test-m"
)
- [
actor: actor,
object: object]
+ [object: object]
end
end
- test "updates name of media", %{conn: conn,
actor: actor,
object: object} do
+ test "updates name of media", %{conn: conn, object: object} do
media =
conn
media =
conn
- |> assign(:user, actor)
|> put("/api/v1/media/#{object.id}", %{"description" => "test-media"})
|> json_response(:ok)
|> put("/api/v1/media/#{object.id}", %{"description" => "test-media"})
|> json_response(:ok)
@@
-79,10
+70,9
@@
defmodule Pleroma.Web.MastodonAPI.MediaControllerTest do
assert refresh_record(object).data["name"] == "test-media"
end
assert refresh_record(object).data["name"] == "test-media"
end
- test "returns error whe
b request is bad", %{conn: conn, actor: actor
, object: object} do
+ test "returns error whe
n request is bad", %{conn: conn
, object: object} do
media =
conn
media =
conn
- |> assign(:user, actor)
|> put("/api/v1/media/#{object.id}", %{})
|> json_response(400)
|> put("/api/v1/media/#{object.id}", %{})
|> json_response(400)