summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRoger Braun <roger@rogerbraun.net>2017-09-14 08:08:32 +0200
committerRoger Braun <roger@rogerbraun.net>2017-09-14 08:08:32 +0200
commit641c24cdd46f36205d91a2de7da8bbbfa7aac3ce (patch)
tree4566a0b4082e3a966bad469ff383272d5e88bcca /test
parent3184939055fb8c1c9577a9d13e69c2c2f7e070c0 (diff)
downloadpleroma-641c24cdd46f36205d91a2de7da8bbbfa7aac3ce.tar.gz
pleroma-641c24cdd46f36205d91a2de7da8bbbfa7aac3ce.zip
Add media upload endpoint.
Diffstat (limited to 'test')
-rw-r--r--test/web/mastodon_api/mastodon_api_controller_test.exs14
-rw-r--r--test/web/mastodon_api/status_view_test.exs4
2 files changed, 18 insertions, 0 deletions
diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs
index fcb3f80f5..d88714cf2 100644
--- a/test/web/mastodon_api/mastodon_api_controller_test.exs
+++ b/test/web/mastodon_api/mastodon_api_controller_test.exs
@@ -213,4 +213,18 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
assert %{"error" => "Can't find user"} = json_response(conn, 404)
end
+
+ test "media upload", %{conn: conn} do
+ file = %Plug.Upload{content_type: "image/jpg", path: Path.absname("test/fixtures/image.jpg"), filename: "an_image.jpg"}
+
+ user = insert(:user)
+
+ conn = conn
+ |> assign(:user, user)
+ |> post("/api/v1/media", %{"file" => file})
+
+ assert media = json_response(conn, 200)
+
+ assert media["type"] == "image"
+ end
end
diff --git a/test/web/mastodon_api/status_view_test.exs b/test/web/mastodon_api/status_view_test.exs
index 198ee72a8..836a47db0 100644
--- a/test/web/mastodon_api/status_view_test.exs
+++ b/test/web/mastodon_api/status_view_test.exs
@@ -76,5 +76,9 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
}
assert expected == StatusView.render("attachment.json", %{attachment: object})
+
+ # If theres a "id", use that instead of the generated one
+ object = Map.put(object, "id", 2)
+ assert %{id: 2} = StatusView.render("attachment.json", %{attachment: object})
end
end