summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorfeld <feld@feld.me>2021-02-26 16:49:11 +0000
committerfeld <feld@feld.me>2021-02-26 16:49:11 +0000
commit840686ecd5b57a210415539d4f5cc1038d25e5ce (patch)
treeb205b3e7acece4cd5ef095f987a00ef9eade1a35 /test
parent2217b35bd40593f5dcfdba4c13dd7b7bded018f3 (diff)
parent1e6c27181e0bbfad3fbd964d770cd4d547c10236 (diff)
Merge branch 'fix/2498-expires_in-scheduled-posts' into 'develop'
expires_in in scheduled status params Closes #2498 See merge request pleroma/pleroma!3315
Diffstat (limited to 'test')
-rw-r--r--test/pleroma/web/mastodon_api/controllers/status_controller_test.exs25
-rw-r--r--test/pleroma/web/mastodon_api/views/scheduled_activity_view_test.exs3
2 files changed, 27 insertions, 1 deletions
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 dcd1e6d5b..c59b156bf 100644
--- a/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs
+++ b/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs
@@ -383,6 +383,31 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
assert [] == Repo.all(Activity)
end
+ test "with expiration" do
+ %{conn: conn} = oauth_access(["write:statuses", "read:statuses"])
+
+ scheduled_at =
+ NaiveDateTime.add(NaiveDateTime.utc_now(), :timer.minutes(6), :millisecond)
+ |> NaiveDateTime.to_iso8601()
+ |> Kernel.<>("Z")
+
+ assert %{"id" => status_id, "params" => %{"expires_in" => 300}} =
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/statuses", %{
+ "status" => "scheduled",
+ "scheduled_at" => scheduled_at,
+ "expires_in" => 300
+ })
+ |> json_response_and_validate_schema(200)
+
+ assert %{"id" => ^status_id, "params" => %{"expires_in" => 300}} =
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> get("/api/v1/scheduled_statuses/#{status_id}")
+ |> json_response_and_validate_schema(200)
+ end
+
test "ignores nil values", %{conn: conn} do
conn =
conn
diff --git a/test/pleroma/web/mastodon_api/views/scheduled_activity_view_test.exs b/test/pleroma/web/mastodon_api/views/scheduled_activity_view_test.exs
index c3b7f0f41..e323f3a1f 100644
--- a/test/pleroma/web/mastodon_api/views/scheduled_activity_view_test.exs
+++ b/test/pleroma/web/mastodon_api/views/scheduled_activity_view_test.exs
@@ -58,7 +58,8 @@ defmodule Pleroma.Web.MastodonAPI.ScheduledActivityViewTest do
sensitive: true,
spoiler_text: "spoiler",
text: "hi",
- visibility: "unlisted"
+ visibility: "unlisted",
+ expires_in: nil
},
scheduled_at: Utils.to_masto_date(scheduled_activity.scheduled_at)
}