diff options
author | feld <feld@feld.me> | 2019-12-11 22:37:16 +0000 |
---|---|---|
committer | feld <feld@feld.me> | 2019-12-11 22:37:16 +0000 |
commit | fd697cf2090b61db60a02694c3227850df176e2d (patch) | |
tree | 8a738fdb98a55713bfe34c9c9c36873466f7c3e6 /test | |
parent | 92b4a1aa1bc750bb077ae45c422967f9712e247d (diff) | |
parent | 086706444145cf008e3413c8ec22c92381865252 (diff) | |
download | pleroma-fd697cf2090b61db60a02694c3227850df176e2d.tar.gz |
Merge branch 'issue/1411' into 'develop'
[#1411] /api/v1/favourites: added sorting for activites by adds to favorites
See merge request pleroma/pleroma!1991
Diffstat (limited to 'test')
-rw-r--r-- | test/web/activity_pub/activity_pub_test.exs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs index 8ae0f45d0..ad1fb6d02 100644 --- a/test/web/activity_pub/activity_pub_test.exs +++ b/test/web/activity_pub/activity_pub_test.exs @@ -1625,6 +1625,38 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do end end + describe "fetch_favourites/3" do + test "returns a favourite activities sorted by adds to favorite" do + user = insert(:user) + other_user = insert(:user) + user1 = insert(:user) + user2 = insert(:user) + {:ok, a1} = CommonAPI.post(user1, %{"status" => "bla"}) + {:ok, _a2} = CommonAPI.post(user2, %{"status" => "traps are happy"}) + {:ok, a3} = CommonAPI.post(user2, %{"status" => "Trees Are "}) + {:ok, a4} = CommonAPI.post(user2, %{"status" => "Agent Smith "}) + {:ok, a5} = CommonAPI.post(user1, %{"status" => "Red or Blue "}) + + {:ok, _, _} = CommonAPI.favorite(a4.id, user) + {:ok, _, _} = CommonAPI.favorite(a3.id, other_user) + Process.sleep(1000) + {:ok, _, _} = CommonAPI.favorite(a3.id, user) + {:ok, _, _} = CommonAPI.favorite(a5.id, other_user) + Process.sleep(1000) + {:ok, _, _} = CommonAPI.favorite(a5.id, user) + {:ok, _, _} = CommonAPI.favorite(a4.id, other_user) + Process.sleep(1000) + {:ok, _, _} = CommonAPI.favorite(a1.id, user) + {:ok, _, _} = CommonAPI.favorite(a1.id, other_user) + result = ActivityPub.fetch_favourites(user) + + assert Enum.map(result, & &1.id) == [a1.id, a5.id, a3.id, a4.id] + + result = ActivityPub.fetch_favourites(user, %{"limit" => 2}) + assert Enum.map(result, & &1.id) == [a1.id, a5.id] + end + end + describe "Move activity" do test "create" do %{ap_id: old_ap_id} = old_user = insert(:user) |