Add tests for privately announcing statuses via API
authorThibaut Girka <thib@sitedethib.com>
Tue, 1 Oct 2019 17:08:25 +0000 (19:08 +0200)
committerThibaut Girka <thib@sitedethib.com>
Tue, 1 Oct 2019 18:38:29 +0000 (20:38 +0200)
test/web/common_api/common_api_test.exs
test/web/mastodon_api/controllers/status_controller_test.exs

index 0f4a5eb25bb251d7029b8abf61dcd6bb1889c17d..2d3c41e82042cfb2934abbd2803da2d19d109043 100644 (file)
@@ -231,6 +231,18 @@ defmodule Pleroma.Web.CommonAPITest do
       {:ok, %Activity{}, _} = CommonAPI.repeat(activity.id, user)
     end
 
+    test "repeating a status privately" do
+      user = insert(:user)
+      other_user = insert(:user)
+
+      {:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
+
+      {:ok, %Activity{} = announce_activity, _} =
+        CommonAPI.repeat(activity.id, user, %{"visibility" => "private"})
+
+      assert Visibility.is_private?(announce_activity)
+    end
+
     test "favoriting a status" do
       user = insert(:user)
       other_user = insert(:user)
index b194feae607ba1fb37a60838869d11eeb7224476..727a233e74bdd0caf8fc823ffd010e0165247cde 100644 (file)
@@ -547,6 +547,24 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
       assert to_string(activity.id) == id
     end
 
+    test "reblogs privately and returns the reblogged status", %{conn: conn} do
+      activity = insert(:note_activity)
+      user = insert(:user)
+
+      conn =
+        conn
+        |> assign(:user, user)
+        |> post("/api/v1/statuses/#{activity.id}/reblog", %{"visibility" => "private"})
+
+      assert %{
+               "reblog" => %{"id" => id, "reblogged" => true, "reblogs_count" => 0},
+               "reblogged" => true,
+               "visibility" => "private"
+             } = json_response(conn, 200)
+
+      assert to_string(activity.id) == id
+    end
+
     test "reblogged status for another user", %{conn: conn} do
       activity = insert(:note_activity)
       user1 = insert(:user)