diff options
author | rinpatch <rinpatch@sdf.org> | 2019-09-26 22:05:33 +0000 |
---|---|---|
committer | rinpatch <rinpatch@sdf.org> | 2019-09-26 22:05:33 +0000 |
commit | 7030721b3141b3390aeac2d0e7f6d355b210117f (patch) | |
tree | a087e5c13d2c553958ab587e0949436b1acec854 /test/web/activity_pub/views | |
parent | b9188361dc518082b01ab3c37ee104615d4f57c8 (diff) | |
parent | df8fda267ec8a748ca436b3feb8b9e18e3a59a5b (diff) | |
download | pleroma-1.0.7.tar.gz |
Merge branch 'backport/1.0-hackney-and-outbox-fixes' into 'master'v1.0.7
Pleroma 1.0.7
See merge request pleroma/pleroma!1723
Diffstat (limited to 'test/web/activity_pub/views')
-rw-r--r-- | test/web/activity_pub/views/user_view_test.exs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/web/activity_pub/views/user_view_test.exs b/test/web/activity_pub/views/user_view_test.exs index e6483db8b..1c725c508 100644 --- a/test/web/activity_pub/views/user_view_test.exs +++ b/test/web/activity_pub/views/user_view_test.exs @@ -4,6 +4,7 @@ defmodule Pleroma.Web.ActivityPub.UserViewTest do alias Pleroma.User alias Pleroma.Web.ActivityPub.UserView + alias Pleroma.Web.CommonAPI test "Renders a user, including the public key" do user = insert(:user) @@ -78,4 +79,35 @@ defmodule Pleroma.Web.ActivityPub.UserViewTest do refute result["endpoints"]["oauthTokenEndpoint"] end end + + test "activity collection page aginates correctly" do + user = insert(:user) + + posts = + for i <- 0..25 do + {:ok, activity} = CommonAPI.post(user, %{"status" => "post #{i}"}) + activity + end + + # outbox sorts chronologically, newest first, with ten per page + posts = Enum.reverse(posts) + + %{"next" => next_url} = + UserView.render("activity_collection_page.json", %{ + iri: "#{user.ap_id}/outbox", + activities: Enum.take(posts, 10) + }) + + next_id = Enum.at(posts, 9).id + assert next_url =~ next_id + + %{"next" => next_url} = + UserView.render("activity_collection_page.json", %{ + iri: "#{user.ap_id}/outbox", + activities: Enum.take(Enum.drop(posts, 10), 10) + }) + + next_id = Enum.at(posts, 19).id + assert next_url =~ next_id + end end |