diff options
author | lain <lain@soykaf.club> | 2018-05-26 16:26:14 +0200 |
---|---|---|
committer | lain <lain@soykaf.club> | 2018-05-26 16:26:14 +0200 |
commit | 46cc6fab078d153b705d841a555471dae102c70a (patch) | |
tree | 081b1ec261dd7d2cd56a77344ccf0b6217ec3996 /test/web/mastodon_api/mastodon_api_controller_test.exs | |
parent | 6138b297836f459e4fe5d21dfed30ddd9397b6d4 (diff) | |
parent | 841ee8e3e4d31d4236a022d46fe18f7751605c74 (diff) | |
download | pleroma-46cc6fab078d153b705d841a555471dae102c70a.tar.gz pleroma-46cc6fab078d153b705d841a555471dae102c70a.zip |
Merge branch 'csaurus/pleroma-feature/mstdn-direct-api' into develop
Diffstat (limited to 'test/web/mastodon_api/mastodon_api_controller_test.exs')
-rw-r--r-- | test/web/mastodon_api/mastodon_api_controller_test.exs | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs index 936d27182..2abcf0dfe 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -124,6 +124,61 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do assert Repo.get(Activity, id) end + test "posting a direct status", %{conn: conn} do + user1 = insert(:user) + user2 = insert(:user) + content = "direct cofe @#{user2.nickname}" + + conn = + conn + |> assign(:user, user1) + |> post("api/v1/statuses", %{"status" => content, "visibility" => "direct"}) + + assert %{"id" => id, "visibility" => "direct"} = json_response(conn, 200) + assert activity = Repo.get(Activity, id) + assert activity.recipients == [user2.ap_id] + assert activity.data["to"] == [user2.ap_id] + assert activity.data["cc"] == [] + end + + test "direct timeline", %{conn: conn} do + user_one = insert(:user) + user_two = insert(:user) + + {:ok, user_two} = User.follow(user_two, user_one) + + {:ok, direct} = + CommonAPI.post(user_one, %{ + "status" => "Hi @#{user_two.nickname}!", + "visibility" => "direct" + }) + + {:ok, _follower_only} = + CommonAPI.post(user_one, %{ + "status" => "Hi @#{user_two.nickname}!", + "visibility" => "private" + }) + + # Only direct should be visible here + res_conn = + conn + |> assign(:user, user_two) + |> get("api/v1/timelines/direct") + + [status] = json_response(res_conn, 200) + + assert %{"visibility" => "direct"} = status + assert status["url"] != direct.data["id"] + + # Both should be visible here + res_conn = + conn + |> assign(:user, user_two) + |> get("api/v1/timelines/home") + + [_s1, _s2] = json_response(res_conn, 200) + end + test "replying to a status", %{conn: conn} do user = insert(:user) |