diff options
author | tusooa <tusooa@kazv.moe> | 2023-03-25 23:20:07 -0400 |
---|---|---|
committer | tusooa <tusooa@kazv.moe> | 2023-03-25 23:20:07 -0400 |
commit | 10930f7507412fb1bea760723ee466774f95c6f3 (patch) | |
tree | 736a0b6be20c234de472fed877ff0d7aceefe7c3 /test | |
parent | 6d0cc8fa2af293280f1816410794d2afdbc2294b (diff) | |
download | pleroma-10930f7507412fb1bea760723ee466774f95c6f3.tar.gz pleroma-10930f7507412fb1bea760723ee466774f95c6f3.zip |
Dedupe poll options
Diffstat (limited to 'test')
-rw-r--r-- | test/pleroma/web/mastodon_api/controllers/status_controller_test.exs | 26 |
1 files changed, 26 insertions, 0 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 5bae2cd00..61d87ffbe 100644 --- a/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs +++ b/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs @@ -724,6 +724,32 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do assert object.data["type"] == "Question" assert length(object.data["oneOf"]) == 3 end + + test "cannot have only one option", %{conn: conn} do + conn = + conn + |> put_req_header("content-type", "application/json") + |> post("/api/v1/statuses", %{ + "status" => "desu~", + "poll" => %{"options" => ["mew"], "expires_in" => 1} + }) + + %{"error" => error} = json_response_and_validate_schema(conn, 422) + assert error == "Poll must contain at least 2 options" + end + + test "cannot have only duplicated options", %{conn: conn} do + conn = + conn + |> put_req_header("content-type", "application/json") + |> post("/api/v1/statuses", %{ + "status" => "desu~", + "poll" => %{"options" => ["mew", "mew"], "expires_in" => 1} + }) + + %{"error" => error} = json_response_and_validate_schema(conn, 422) + assert error == "Poll must contain at least 2 options" + end end test "get a status" do |