aboutsummaryrefslogtreecommitdiff
path: root/test/pleroma/web
diff options
context:
space:
mode:
Diffstat (limited to 'test/pleroma/web')
-rw-r--r--test/pleroma/web/common_api/utils_test.exs10
-rw-r--r--test/pleroma/web/mastodon_api/controllers/status_controller_test.exs12
2 files changed, 22 insertions, 0 deletions
diff --git a/test/pleroma/web/common_api/utils_test.exs b/test/pleroma/web/common_api/utils_test.exs
index d8fec3520..a12332cad 100644
--- a/test/pleroma/web/common_api/utils_test.exs
+++ b/test/pleroma/web/common_api/utils_test.exs
@@ -655,6 +655,16 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do
assert Utils.attachments_from_ids(%{media_ids: ["#{object.id}"]}) == [object.data]
end
+ test "returns attachment object with raw URL" do
+ assert Utils.attachments_from_ids(%{media_ids: ["https://example.org/corndog.jpeg"]}) == [
+ %{
+ "name" => nil,
+ "type" => "Document",
+ "url" => [%{"href" => "https://example.org/corndog.jpeg", "type" => "Link"}]
+ }
+ ]
+ end
+
test "returns [] when not pass media_ids" do
assert Utils.attachments_from_ids(%{}) == []
end
diff --git a/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs
index ed66d370a..73dfd40f1 100644
--- a/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs
+++ b/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs
@@ -182,6 +182,18 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
assert json_response_and_validate_schema(conn, 200)
end
+ test "posting an undefined status with arbitrary URL as attachment", %{conn: conn} do
+ assert response =
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/statuses", %{
+ "media_ids" => ["https://example.org/corndog.jpeg"]
+ })
+ |> json_response_and_validate_schema(200)
+
+ assert [%{"url" => "https://example.org/corndog.jpeg"}] = response["media_attachments"]
+ end
+
test "replying to a status", %{user: user, conn: conn} do
{:ok, replied_to} = CommonAPI.post(user, %{status: "cofe"})