1
0
Fork 1
mirror of https://akkoma.dev/AkkomaGang/akkoma.git synced 2024-12-25 04:53:06 +00:00

Ensure newest report is returned first in the list

This commit is contained in:
Mark Felder 2020-12-31 10:53:18 -06:00
parent 744b34709d
commit e4791258d4

View file

@ -143,4 +143,29 @@ test "doesn't error out when the user doesn't exists" do
assert %{} = ReportView.render("show.json", Report.extract_report_info(activity))
end
test "reports are ordered newest first" do
user = insert(:user)
other_user = insert(:user)
{:ok, report1} =
CommonAPI.report(user, %{
account_id: other_user.id,
comment: "first report"
})
{:ok, report2} =
CommonAPI.report(user, %{
account_id: other_user.id,
comment: "second report"
})
%{reports: rendered} =
ReportView.render("index.json",
reports: Pleroma.Web.ActivityPub.Utils.get_reports(%{}, 1, 50)
)
assert report2.id == rendered |> Enum.at(0) |> Map.get(:id)
assert report1.id == rendered |> Enum.at(1) |> Map.get(:id)
end
end