Add a test
authorEgor Kislitsyn <egor@kislitsyn.com>
Tue, 18 Feb 2020 13:09:50 +0000 (17:09 +0400)
committerEgor Kislitsyn <egor@kislitsyn.com>
Tue, 18 Feb 2020 13:09:50 +0000 (17:09 +0400)
test/web/mastodon_api/controllers/status_controller_test.exs

index 810f371cb756078f5ea21348e0cf4ac40ac19001..fd2e40ce29a2dd16026114b546ea974efd672d19 100644 (file)
@@ -1254,4 +1254,23 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
 
     assert [] = json_response(third_conn, 200)
   end
+
+  test "expires_at is nil for another user" do
+    %{conn: conn, user: user} = oauth_access(["read:statuses"])
+    {:ok, activity} = CommonAPI.post(user, %{"status" => "foobar", "expires_in" => 1_000_000})
+
+    expires_at =
+      activity.id
+      |> ActivityExpiration.get_by_activity_id()
+      |> Map.get(:scheduled_at)
+      |> NaiveDateTime.to_iso8601()
+
+    assert %{"pleroma" => %{"expires_at" => ^expires_at}} =
+             conn |> get("/api/v1/statuses/#{activity.id}") |> json_response(:ok)
+
+    %{conn: conn} = oauth_access(["read:statuses"])
+
+    assert %{"pleroma" => %{"expires_at" => nil}} =
+             conn |> get("/api/v1/statuses/#{activity.id}") |> json_response(:ok)
+  end
 end