X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=test%2Fpleroma%2Fweb%2Fmastodon_api%2Fcontrollers%2Fstatus_controller_test.exs;h=cda4c9e03bedb093746870969c22a980b5acbdae;hb=0cfd5b4e89b02688342345755577e58eece3db0f;hp=ea6ace69f5ac60529e6881b22651be1511d85725;hpb=2d019e14e386fdd3391bb6d0bf36348dad78b075;p=akkoma 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 ea6ace69f..cda4c9e03 100644 --- a/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs +++ b/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs @@ -126,6 +126,35 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do ) end + test "automatically setting a post expiry if status_ttl_days is set" do + user = insert(:user, status_ttl_days: 1) + %{user: _user, token: _token, conn: conn} = oauth_access(["write:statuses"], user: user) + + conn = + conn + |> put_req_header("content-type", "application/json") + |> post("api/v1/statuses", %{ + "status" => "aa chikichiki banban" + }) + + assert %{"id" => id} = json_response_and_validate_schema(conn, 200) + + activity = Activity.get_by_id_with_object(id) + {:ok, expires_at, _} = DateTime.from_iso8601(activity.data["expires_at"]) + + assert Timex.diff( + expires_at, + DateTime.utc_now(), + :hours + ) == 23 + + assert_enqueued( + worker: Pleroma.Workers.PurgeExpiredActivity, + args: %{activity_id: id}, + scheduled_at: DateTime.add(DateTime.utc_now(), 1 * 60 * 60 * 24) + ) + end + test "it fails to create a status if `expires_in` is less or equal than an hour", %{ conn: conn } do