aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authoreugenijm <eugenijm@protonmail.com>2019-03-07 05:29:42 +0300
committereugenijm <eugenijm@protonmail.com>2019-03-07 09:12:16 +0300
commit7342b5a45f8a31fe33dac21123d707071531aa95 (patch)
tree1aefd007cb762909dae807f400c6477f8dee9508 /test
parent0fe715f3ba0f787154ab8e86c8745d7f09affdcb (diff)
downloadpleroma-7342b5a45f8a31fe33dac21123d707071531aa95.tar.gz
Preserve parameters in link headers (Mastodon API)
Diffstat (limited to 'test')
-rw-r--r--test/web/mastodon_api/mastodon_api_controller_test.exs32
1 files changed, 32 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 ec6869db9..ffba5e3de 100644
--- a/test/web/mastodon_api/mastodon_api_controller_test.exs
+++ b/test/web/mastodon_api/mastodon_api_controller_test.exs
@@ -1955,4 +1955,36 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|> json_response(400)
end
end
+
+ describe "link headers" do
+ test "preserves parameters in link headers", %{conn: conn} do
+ user = insert(:user)
+ other_user = insert(:user)
+
+ {:ok, activity1} =
+ CommonAPI.post(other_user, %{
+ "status" => "hi @#{user.nickname}",
+ "visibility" => "public"
+ })
+
+ {:ok, activity2} =
+ CommonAPI.post(other_user, %{
+ "status" => "hi @#{user.nickname}",
+ "visibility" => "public"
+ })
+
+ notification1 = Repo.get_by(Notification, activity_id: activity1.id)
+ notification2 = Repo.get_by(Notification, activity_id: activity2.id)
+
+ conn =
+ conn
+ |> assign(:user, user)
+ |> get("/api/v1/notifications", %{media_only: true})
+
+ 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/max_id=#{notification1.id}/
+ end
+ end
end