Mastodon API: Add support for posting polls
This commit is contained in:
parent
642a67dd44
commit
fd920c8973
4 changed files with 82 additions and 9 deletions
|
|
@ -132,6 +132,28 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
refute id == third_id
|
||||
end
|
||||
|
||||
test "posting a poll", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
time = NaiveDateTime.utc_now()
|
||||
|
||||
conn =
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> post("/api/v1/statuses", %{
|
||||
"status" => "Who is the best girl?",
|
||||
"poll" => %{"options" => ["Rei", "Asuka", "Misato"], "expires_in" => 420}
|
||||
})
|
||||
|
||||
response = json_response(conn, 200)
|
||||
|
||||
assert Enum.all?(response["poll"]["options"], fn %{"title" => title} ->
|
||||
title in ["Rei", "Asuka", "Misato"]
|
||||
end)
|
||||
|
||||
assert NaiveDateTime.diff(NaiveDateTime.from_iso8601!(response["poll"]["expires_at"]), time) in 420..430
|
||||
refute response["poll"]["expred"]
|
||||
end
|
||||
|
||||
test "posting a sensitive status", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
|
||||
|
|
|
|||
|
|
@ -103,6 +103,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
muted: false,
|
||||
pinned: false,
|
||||
sensitive: false,
|
||||
poll: nil,
|
||||
spoiler_text: HtmlSanitizeEx.basic_html(note.data["object"]["summary"]),
|
||||
visibility: "public",
|
||||
media_attachments: [],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue