diff options
| author | Egor Kislitsyn <egor@kislitsyn.com> | 2020-02-12 19:43:07 +0400 | 
|---|---|---|
| committer | Egor Kislitsyn <egor@kislitsyn.com> | 2020-02-12 20:20:44 +0400 | 
| commit | 19516af74e9cc8bacc3edf473eab0f54955368f4 (patch) | |
| tree | aba1c4f7c8671da738856d701cfa3b8742461601 /test | |
| parent | d056f7f722b5e734ac53d8b55a0228174d64cc9f (diff) | |
| download | pleroma-19516af74e9cc8bacc3edf473eab0f54955368f4.tar.gz pleroma-19516af74e9cc8bacc3edf473eab0f54955368f4.zip | |
Fix `status.expires_in` validation
Diffstat (limited to 'test')
| -rw-r--r-- | test/web/mastodon_api/controllers/status_controller_test.exs | 26 | 
1 files changed, 26 insertions, 0 deletions
| diff --git a/test/web/mastodon_api/controllers/status_controller_test.exs b/test/web/mastodon_api/controllers/status_controller_test.exs index 83138d7ef..810f371cb 100644 --- a/test/web/mastodon_api/controllers/status_controller_test.exs +++ b/test/web/mastodon_api/controllers/status_controller_test.exs @@ -121,6 +121,32 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do                 NaiveDateTime.to_iso8601(expiration.scheduled_at)      end +    test "it fails to create a status if `expires_in` is less or equal than an hour", %{ +      conn: conn +    } do +      # 1 hour +      expires_in = 60 * 60 + +      assert %{"error" => "Expiry date is too soon"} = +               conn +               |> post("api/v1/statuses", %{ +                 "status" => "oolong", +                 "expires_in" => expires_in +               }) +               |> json_response(422) + +      # 30 minutes +      expires_in = 30 * 60 + +      assert %{"error" => "Expiry date is too soon"} = +               conn +               |> post("api/v1/statuses", %{ +                 "status" => "oolong", +                 "expires_in" => expires_in +               }) +               |> json_response(422) +    end +      test "posting an undefined status with an attachment", %{user: user, conn: conn} do        file = %Plug.Upload{          content_type: "image/jpg", | 
