Questions: Add timezone to `closed` property
authorLain Soykaf <lain@soykaf.club>
Fri, 7 Feb 2020 15:57:46 +0000 (16:57 +0100)
committerLain Soykaf <lain@soykaf.club>
Fri, 7 Feb 2020 15:57:46 +0000 (16:57 +0100)
lib/pleroma/web/common_api/utils.ex
test/web/mastodon_api/controllers/status_controller_test.exs

index a9b164d9ac88a177d0e513aa31f1bb64ee427629..ca6c9386276178b0eb68fa6eaafc3453c7067270 100644 (file)
@@ -179,9 +179,9 @@ defmodule Pleroma.Web.CommonAPI.Utils do
         end)
 
       end_time =
-        NaiveDateTime.utc_now()
-        |> NaiveDateTime.add(expires_in)
-        |> NaiveDateTime.to_iso8601()
+        DateTime.utc_now()
+        |> DateTime.add(expires_in)
+        |> DateTime.to_iso8601()
 
       key = if truthy_param?(data["poll"]["multiple"]), do: "anyOf", else: "oneOf"
       poll = %{"type" => "Question", key => option_notes, "closed" => end_time}
index b03b4b344904ab42904052b47eef3ebd590996ca..83138d7ef9b2bd07fdc8d93e3d72f5cb53054100 100644 (file)
@@ -370,6 +370,11 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
 
       assert NaiveDateTime.diff(NaiveDateTime.from_iso8601!(response["poll"]["expires_at"]), time) in 420..430
       refute response["poll"]["expred"]
+
+      question = Object.get_by_id(response["poll"]["id"])
+
+      # closed contains utc timezone
+      assert question.data["closed"] =~ "Z"
     end
 
     test "option limit is enforced", %{conn: conn} do