Merge branch 'openapi/statuses' into 'develop'
authorlain <lain@soykaf.club>
Wed, 13 May 2020 09:34:30 +0000 (09:34 +0000)
committerlain <lain@soykaf.club>
Wed, 13 May 2020 09:34:30 +0000 (09:34 +0000)
Add OpenAPI spec for StatusController

See merge request pleroma/pleroma!2521

1  2 
test/web/mastodon_api/controllers/timeline_controller_test.exs

index 5e0d92f28ace6f94bcdfd60091bc81b6bdf37fc8,6d8f81b75ac30817d28aa1f74ca969f78d0d8f87..f8b9289f37cb04c7d893e667ea3d8d7b152a9efd
@@@ -108,18 -108,16 +108,16 @@@ defmodule Pleroma.Web.MastodonAPI.Timel
      end
  
      test "the home timeline when the direct messages are excluded", %{user: user, conn: conn} do
-       {:ok, public_activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "public"})
-       {:ok, direct_activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "direct"})
+       {:ok, public_activity} = CommonAPI.post(user, %{status: ".", visibility: "public"})
+       {:ok, direct_activity} = CommonAPI.post(user, %{status: ".", visibility: "direct"})
  
-       {:ok, unlisted_activity} =
-         CommonAPI.post(user, %{"status" => ".", "visibility" => "unlisted"})
+       {:ok, unlisted_activity} = CommonAPI.post(user, %{status: ".", visibility: "unlisted"})
  
-       {:ok, private_activity} =
-         CommonAPI.post(user, %{"status" => ".", "visibility" => "private"})
+       {:ok, private_activity} = CommonAPI.post(user, %{status: ".", visibility: "private"})
  
 -      conn = get(conn, "/api/v1/timelines/home", %{"exclude_visibilities" => ["direct"]})
 +      conn = get(conn, "/api/v1/timelines/home?exclude_visibilities[]=direct")
  
 -      assert status_ids = json_response(conn, :ok) |> Enum.map(& &1["id"])
 +      assert status_ids = json_response_and_validate_schema(conn, :ok) |> Enum.map(& &1["id"])
        assert public_activity.id in status_ids
        assert unlisted_activity.id in status_ids
        assert private_activity.id in status_ids
      test "the public timeline includes only public statuses for an authenticated user" do
        %{user: user, conn: conn} = oauth_access(["read:statuses"])
  
-       {:ok, _activity} = CommonAPI.post(user, %{"status" => "test"})
-       {:ok, _activity} = CommonAPI.post(user, %{"status" => "test", "visibility" => "private"})
-       {:ok, _activity} = CommonAPI.post(user, %{"status" => "test", "visibility" => "unlisted"})
-       {:ok, _activity} = CommonAPI.post(user, %{"status" => "test", "visibility" => "direct"})
+       {:ok, _activity} = CommonAPI.post(user, %{status: "test"})
+       {:ok, _activity} = CommonAPI.post(user, %{status: "test", visibility: "private"})
+       {:ok, _activity} = CommonAPI.post(user, %{status: "test", visibility: "unlisted"})
+       {:ok, _activity} = CommonAPI.post(user, %{status: "test", visibility: "direct"})
  
        res_conn = get(conn, "/api/v1/timelines/public")
 -      assert length(json_response(res_conn, 200)) == 1
 +      assert length(json_response_and_validate_schema(res_conn, 200)) == 1
      end
    end
  
      test "multi-hashtag timeline", %{conn: conn} do
        user = insert(:user)
  
-       {:ok, activity_test} = CommonAPI.post(user, %{"status" => "#test"})
-       {:ok, activity_test1} = CommonAPI.post(user, %{"status" => "#test #test1"})
-       {:ok, activity_none} = CommonAPI.post(user, %{"status" => "#test #none"})
+       {:ok, activity_test} = CommonAPI.post(user, %{status: "#test"})
+       {:ok, activity_test1} = CommonAPI.post(user, %{status: "#test #test1"})
+       {:ok, activity_none} = CommonAPI.post(user, %{status: "#test #none"})
  
 -      any_test = get(conn, "/api/v1/timelines/tag/test", %{"any" => ["test1"]})
 +      any_test = get(conn, "/api/v1/timelines/tag/test?any[]=test1")
  
 -      [status_none, status_test1, status_test] = json_response(any_test, :ok)
 +      [status_none, status_test1, status_test] = json_response_and_validate_schema(any_test, :ok)
  
        assert to_string(activity_test.id) == status_test["id"]
        assert to_string(activity_test1.id) == status_test1["id"]