aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex S <alex.strizhakov@gmail.com>2019-04-13 12:24:38 +0700
committerAlex S <alex.strizhakov@gmail.com>2019-04-13 12:24:38 +0700
commitc349573791bfaca6e8c8c86c519c23397b088967 (patch)
treed98225031c8ad1b3efe7c2917fd911d369953ca7 /test
parenta64eb2b3893cee61f50d89b6ad4d273031ef0ea9 (diff)
parent334b2d78dc068f65fabf5b11aaa737dfd742d2f4 (diff)
downloadpleroma-c349573791bfaca6e8c8c86c519c23397b088967.tar.gz
Merge develop to 788-separate-email-addresses
Merge conflicts: test/web/twitter_api/twitter_api_test.exs test/web/twitter_api/twitter_api_controller_test.exs test/web/admin_api/admin_api_controller_test.exs
Diffstat (limited to 'test')
-rw-r--r--test/web/mastodon_api/mastodon_api_controller_test.exs103
1 files changed, 100 insertions, 3 deletions
diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs
index 614b950ba..b3039a7b5 100644
--- a/test/web/mastodon_api/mastodon_api_controller_test.exs
+++ b/test/web/mastodon_api/mastodon_api_controller_test.exs
@@ -944,6 +944,58 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
assert [%{"id" => ^reblog_notification_id}] = json_response(conn_res, 200)
end
+
+ test "destroy multiple", %{conn: conn} do
+ user = insert(:user)
+ other_user = insert(:user)
+
+ {:ok, activity1} = CommonAPI.post(other_user, %{"status" => "hi @#{user.nickname}"})
+ {:ok, activity2} = CommonAPI.post(other_user, %{"status" => "hi @#{user.nickname}"})
+ {:ok, activity3} = CommonAPI.post(user, %{"status" => "hi @#{other_user.nickname}"})
+ {:ok, activity4} = CommonAPI.post(user, %{"status" => "hi @#{other_user.nickname}"})
+
+ notification1_id = Repo.get_by(Notification, activity_id: activity1.id).id |> to_string()
+ notification2_id = Repo.get_by(Notification, activity_id: activity2.id).id |> to_string()
+ notification3_id = Repo.get_by(Notification, activity_id: activity3.id).id |> to_string()
+ notification4_id = Repo.get_by(Notification, activity_id: activity4.id).id |> to_string()
+
+ conn =
+ conn
+ |> assign(:user, user)
+
+ conn_res =
+ conn
+ |> get("/api/v1/notifications")
+
+ result = json_response(conn_res, 200)
+ assert [%{"id" => ^notification2_id}, %{"id" => ^notification1_id}] = result
+
+ conn2 =
+ conn
+ |> assign(:user, other_user)
+
+ conn_res =
+ conn2
+ |> get("/api/v1/notifications")
+
+ result = json_response(conn_res, 200)
+ assert [%{"id" => ^notification4_id}, %{"id" => ^notification3_id}] = result
+
+ conn_destroy =
+ conn
+ |> delete("/api/v1/notifications/destroy_multiple", %{
+ "ids" => [notification1_id, notification2_id]
+ })
+
+ assert json_response(conn_destroy, 200) == %{}
+
+ conn_res =
+ conn2
+ |> get("/api/v1/notifications")
+
+ result = json_response(conn_res, 200)
+ assert [%{"id" => ^notification4_id}, %{"id" => ^notification3_id}] = result
+ end
end
describe "reblogging" do
@@ -1421,7 +1473,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
assert id2 == follower2.id
assert [link_header] = get_resp_header(res_conn, "link")
- assert link_header =~ ~r/since_id=#{follower2.id}/
+ assert link_header =~ ~r/min_id=#{follower2.id}/
assert link_header =~ ~r/max_id=#{follower2.id}/
end
@@ -1500,7 +1552,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
assert id2 == following2.id
assert [link_header] = get_resp_header(res_conn, "link")
- assert link_header =~ ~r/since_id=#{following2.id}/
+ assert link_header =~ ~r/min_id=#{following2.id}/
assert link_header =~ ~r/max_id=#{following2.id}/
end
@@ -2333,7 +2385,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
assert [link_header] = get_resp_header(conn, "link")
assert link_header =~ ~r/media_only=true/
- assert link_header =~ ~r/since_id=#{notification2.id}/
+ assert link_header =~ ~r/min_id=#{notification2.id}/
assert link_header =~ ~r/max_id=#{notification1.id}/
end
end
@@ -2656,4 +2708,49 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
assert %{"error" => "Record not found"} = json_response(res_conn, 404)
end
end
+
+ test "Repeated posts that are replies incorrectly have in_reply_to_id null", %{conn: conn} do
+ user1 = insert(:user)
+ user2 = insert(:user)
+ user3 = insert(:user)
+
+ {:ok, replied_to} = TwitterAPI.create_status(user1, %{"status" => "cofe"})
+
+ # Reply to status from another user
+ conn1 =
+ conn
+ |> assign(:user, user2)
+ |> post("/api/v1/statuses", %{"status" => "xD", "in_reply_to_id" => replied_to.id})
+
+ assert %{"content" => "xD", "id" => id} = json_response(conn1, 200)
+
+ activity = Activity.get_by_id(id)
+
+ assert activity.data["object"]["inReplyTo"] == replied_to.data["object"]["id"]
+ assert activity.data["object"]["inReplyToStatusId"] == replied_to.id
+
+ # Reblog from the third user
+ conn2 =
+ conn
+ |> assign(:user, user3)
+ |> post("/api/v1/statuses/#{activity.id}/reblog")
+
+ assert %{"reblog" => %{"id" => id, "reblogged" => true, "reblogs_count" => 1}} =
+ json_response(conn2, 200)
+
+ assert to_string(activity.id) == id
+
+ # Getting third user status
+ conn3 =
+ conn
+ |> assign(:user, user3)
+ |> get("api/v1/timelines/home")
+
+ [reblogged_activity] = json_response(conn3, 200)
+
+ assert reblogged_activity["reblog"]["in_reply_to_id"] == replied_to.id
+
+ replied_to_user = User.get_by_ap_id(replied_to.data["actor"])
+ assert reblogged_activity["reblog"]["in_reply_to_account_id"] == replied_to_user.id
+ end
end