diff options
author | eugenijm <eugenijm@protonmail.com> | 2019-04-02 01:31:01 +0300 |
---|---|---|
committer | eugenijm <eugenijm@protonmail.com> | 2019-04-06 23:55:58 +0300 |
commit | fc92a0fd8d5be0352f4791b79bda04960f36f707 (patch) | |
tree | 344c6f7dff59caf0cb93eaf3ffb8c0610e3e0c0e /test/web/mastodon_api/mastodon_api_controller_test.exs | |
parent | b3870df51fb2f35c3e51bea435134fe3fb692ef8 (diff) | |
download | pleroma-fc92a0fd8d5be0352f4791b79bda04960f36f707.tar.gz pleroma-fc92a0fd8d5be0352f4791b79bda04960f36f707.zip |
Added limits and media attachments for scheduled activities.
Diffstat (limited to 'test/web/mastodon_api/mastodon_api_controller_test.exs')
-rw-r--r-- | test/web/mastodon_api/mastodon_api_controller_test.exs | 25 |
1 files changed, 25 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 0ec66ab73..ae2375696 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -2427,6 +2427,31 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do assert [] == Repo.all(Activity) end + test "creates a scheduled activity with a media attachment", %{conn: conn} do + user = insert(:user) + scheduled_at = NaiveDateTime.add(NaiveDateTime.utc_now(), :timer.minutes(120), :millisecond) + + file = %Plug.Upload{ + content_type: "image/jpg", + path: Path.absname("test/fixtures/image.jpg"), + filename: "an_image.jpg" + } + + {:ok, upload} = ActivityPub.upload(file, actor: user.ap_id) + + conn = + conn + |> assign(:user, user) + |> post("/api/v1/statuses", %{ + "media_ids" => [to_string(upload.id)], + "status" => "scheduled", + "scheduled_at" => scheduled_at + }) + + assert %{"media_attachments" => [media_attachment]} = json_response(conn, 200) + assert %{"type" => "image"} = media_attachment + end + test "skips the scheduling and creates the activity if scheduled_at is earlier than 5 minutes from now", %{conn: conn} do user = insert(:user) |