X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;ds=sidebyside;f=test%2Fweb%2Fmastodon_api%2Fcontrollers%2Fmedia_controller_test.exs;h=203fa73b029e1d4216900761f297c9848037834f;hb=4271cfb81a8983f5ec6a878cab1fb3fbd164245d;hp=06c6a1cb31e847e0797e886fdac7834f9930e935;hpb=fd6d05dc45e2fdff56e777431b303fc24ef7912f;p=akkoma
diff --git a/test/web/mastodon_api/controllers/media_controller_test.exs b/test/web/mastodon_api/controllers/media_controller_test.exs
index 06c6a1cb3..203fa73b0 100644
--- 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
-# Copyright © 2017-2019 Pleroma Authors
+# Copyright © 2017-2020 Pleroma Authors
# 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
- import Pleroma.Factory
+ setup do: oauth_access(["write:media"])
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"
}
- [conn: conn, image: image]
+ [image: image]
end
clear_config([:media_proxy])
@@ -49,9 +43,7 @@ defmodule Pleroma.Web.MastodonAPI.MediaControllerTest 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"),
@@ -65,13 +57,12 @@ defmodule Pleroma.Web.MastodonAPI.MediaControllerTest do
description: "test-m"
)
- [actor: actor, object: object]
+ [object: object]
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
- |> assign(:user, actor)
|> 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
- test "returns error wheb request is bad", %{conn: conn, actor: actor, object: object} do
+ test "returns error when request is bad", %{conn: conn, object: object} do
media =
conn
- |> assign(:user, actor)
|> put("/api/v1/media/#{object.id}", %{})
|> json_response(400)