Questions: Add timezone to `closed` property

This commit is contained in:
Lain Soykaf 2020-02-07 16:57:46 +01:00
parent f13b7878b4
commit d85bcc8627
2 changed files with 8 additions and 3 deletions

View File

@ -179,9 +179,9 @@ def make_poll_data(%{"poll" => %{"options" => options, "expires_in" => expires_i
end) end)
end_time = end_time =
NaiveDateTime.utc_now() DateTime.utc_now()
|> NaiveDateTime.add(expires_in) |> DateTime.add(expires_in)
|> NaiveDateTime.to_iso8601() |> DateTime.to_iso8601()
key = if truthy_param?(data["poll"]["multiple"]), do: "anyOf", else: "oneOf" key = if truthy_param?(data["poll"]["multiple"]), do: "anyOf", else: "oneOf"
poll = %{"type" => "Question", key => option_notes, "closed" => end_time} poll = %{"type" => "Question", key => option_notes, "closed" => end_time}

View File

@ -370,6 +370,11 @@ test "posting a poll", %{conn: conn} do
assert NaiveDateTime.diff(NaiveDateTime.from_iso8601!(response["poll"]["expires_at"]), time) in 420..430 assert NaiveDateTime.diff(NaiveDateTime.from_iso8601!(response["poll"]["expires_at"]), time) in 420..430
refute response["poll"]["expred"] refute response["poll"]["expred"]
question = Object.get_by_id(response["poll"]["id"])
# closed contains utc timezone
assert question.data["closed"] =~ "Z"
end end
test "option limit is enforced", %{conn: conn} do test "option limit is enforced", %{conn: conn} do