diff options
Diffstat (limited to 'test/web/mastodon_api/controllers')
| -rw-r--r-- | test/web/mastodon_api/controllers/account_controller_test.exs | 43 | ||||
| -rw-r--r-- | test/web/mastodon_api/controllers/follow_request_controller_test.exs | 8 | 
2 files changed, 42 insertions, 9 deletions
| diff --git a/test/web/mastodon_api/controllers/account_controller_test.exs b/test/web/mastodon_api/controllers/account_controller_test.exs index 260ad2306..9c7b5e9b2 100644 --- a/test/web/mastodon_api/controllers/account_controller_test.exs +++ b/test/web/mastodon_api/controllers/account_controller_test.exs @@ -708,7 +708,10 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do        followed = insert(:user)        other_user = insert(:user) -      ret_conn = post(conn, "/api/v1/accounts/#{followed.id}/follow?reblogs=false") +      ret_conn = +        conn +        |> put_req_header("content-type", "application/json") +        |> post("/api/v1/accounts/#{followed.id}/follow", %{reblogs: false})        assert %{"showing_reblogs" => false} = json_response_and_validate_schema(ret_conn, 200) @@ -722,7 +725,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do        assert %{"showing_reblogs" => true} =                 conn -               |> post("/api/v1/accounts/#{followed.id}/follow?reblogs=true") +               |> put_req_header("content-type", "application/json") +               |> post("/api/v1/accounts/#{followed.id}/follow", %{reblogs: true})                 |> json_response_and_validate_schema(200)        assert [%{"id" => ^reblog_id}] = @@ -731,6 +735,35 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do                 |> json_response(200)      end +    test "following with reblogs" do +      %{conn: conn} = oauth_access(["follow", "read:statuses"]) +      followed = insert(:user) +      other_user = insert(:user) + +      ret_conn = post(conn, "/api/v1/accounts/#{followed.id}/follow") + +      assert %{"showing_reblogs" => true} = json_response_and_validate_schema(ret_conn, 200) + +      {:ok, activity} = CommonAPI.post(other_user, %{status: "hey"}) +      {:ok, %{id: reblog_id}} = CommonAPI.repeat(activity.id, followed) + +      assert [%{"id" => ^reblog_id}] = +               conn +               |> get("/api/v1/timelines/home") +               |> json_response(200) + +      assert %{"showing_reblogs" => false} = +               conn +               |> put_req_header("content-type", "application/json") +               |> post("/api/v1/accounts/#{followed.id}/follow", %{reblogs: false}) +               |> json_response_and_validate_schema(200) + +      assert [] == +               conn +               |> get("/api/v1/timelines/home") +               |> json_response(200) +    end +      test "following / unfollowing errors", %{user: user, conn: conn} do        # self follow        conn_res = post(conn, "/api/v1/accounts/#{user.id}/follow") @@ -904,7 +937,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do        %{          "access_token" => token,          "created_at" => _created_at, -        "scope" => _scope, +        "scope" => ^scope,          "token_type" => "Bearer"        } = json_response_and_validate_schema(conn, 200) @@ -1066,7 +1099,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do        assert %{                 "access_token" => access_token,                 "created_at" => _, -               "scope" => ["read", "write", "follow", "push"], +               "scope" => "read write follow push",                 "token_type" => "Bearer"               } = response @@ -1184,7 +1217,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do        assert %{                 "access_token" => access_token,                 "created_at" => _, -               "scope" => ["read"], +               "scope" => "read",                 "token_type" => "Bearer"               } =                 conn diff --git a/test/web/mastodon_api/controllers/follow_request_controller_test.exs b/test/web/mastodon_api/controllers/follow_request_controller_test.exs index 44e12d15a..6749e0e83 100644 --- a/test/web/mastodon_api/controllers/follow_request_controller_test.exs +++ b/test/web/mastodon_api/controllers/follow_request_controller_test.exs @@ -6,7 +6,7 @@ defmodule Pleroma.Web.MastodonAPI.FollowRequestControllerTest do    use Pleroma.Web.ConnCase    alias Pleroma.User -  alias Pleroma.Web.ActivityPub.ActivityPub +  alias Pleroma.Web.CommonAPI    import Pleroma.Factory @@ -20,7 +20,7 @@ defmodule Pleroma.Web.MastodonAPI.FollowRequestControllerTest do      test "/api/v1/follow_requests works", %{user: user, conn: conn} do        other_user = insert(:user) -      {:ok, _activity} = ActivityPub.follow(other_user, user) +      {:ok, _, _, _activity} = CommonAPI.follow(other_user, user)        {:ok, other_user} = User.follow(other_user, user, :follow_pending)        assert User.following?(other_user, user) == false @@ -34,7 +34,7 @@ defmodule Pleroma.Web.MastodonAPI.FollowRequestControllerTest do      test "/api/v1/follow_requests/:id/authorize works", %{user: user, conn: conn} do        other_user = insert(:user) -      {:ok, _activity} = ActivityPub.follow(other_user, user) +      {:ok, _, _, _activity} = CommonAPI.follow(other_user, user)        {:ok, other_user} = User.follow(other_user, user, :follow_pending)        user = User.get_cached_by_id(user.id) @@ -56,7 +56,7 @@ defmodule Pleroma.Web.MastodonAPI.FollowRequestControllerTest do      test "/api/v1/follow_requests/:id/reject works", %{user: user, conn: conn} do        other_user = insert(:user) -      {:ok, _activity} = ActivityPub.follow(other_user, user) +      {:ok, _, _, _activity} = CommonAPI.follow(other_user, user)        user = User.get_cached_by_id(user.id) | 
