aboutsummaryrefslogtreecommitdiff
path: root/test/web/mastodon_api/controllers
diff options
context:
space:
mode:
authorEgor Kislitsyn <egor@kislitsyn.com>2019-09-26 14:28:35 +0700
committerEgor Kislitsyn <egor@kislitsyn.com>2019-09-27 10:52:47 +0700
commit5ea5c58a85b7be56370b151ce8977982d47fde8c (patch)
treea48af9bf72549d691386ca01f0be3f1ca8db4926 /test/web/mastodon_api/controllers
parent76b7e5cd5b34e68055bab7353cb845f3429d897f (diff)
downloadpleroma-5ea5c58a85b7be56370b151ce8977982d47fde8c.tar.gz
Move view logic from StatusController.context to StatusView and add a test
Diffstat (limited to 'test/web/mastodon_api/controllers')
-rw-r--r--test/web/mastodon_api/controllers/status_controller_test.exs21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/web/mastodon_api/controllers/status_controller_test.exs b/test/web/mastodon_api/controllers/status_controller_test.exs
index f80ce7704..14c7bd6d9 100644
--- a/test/web/mastodon_api/controllers/status_controller_test.exs
+++ b/test/web/mastodon_api/controllers/status_controller_test.exs
@@ -1053,4 +1053,25 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
assert [] == response
end
end
+
+ test "context" do
+ user = insert(:user)
+
+ {:ok, %{id: id1}} = CommonAPI.post(user, %{"status" => "1"})
+ {:ok, %{id: id2}} = CommonAPI.post(user, %{"status" => "2", "in_reply_to_status_id" => id1})
+ {:ok, %{id: id3}} = CommonAPI.post(user, %{"status" => "3", "in_reply_to_status_id" => id2})
+ {:ok, %{id: id4}} = CommonAPI.post(user, %{"status" => "4", "in_reply_to_status_id" => id3})
+ {:ok, %{id: id5}} = CommonAPI.post(user, %{"status" => "5", "in_reply_to_status_id" => id4})
+
+ response =
+ build_conn()
+ |> assign(:user, nil)
+ |> get("/api/v1/statuses/#{id3}/context")
+ |> json_response(:ok)
+
+ assert %{
+ "ancestors" => [%{"id" => ^id1}, %{"id" => ^id2}],
+ "descendants" => [%{"id" => ^id4}, %{"id" => ^id5}]
+ } = response
+ end
end