diff options
author | Maxim Filippov <colixer@gmail.com> | 2019-08-27 20:48:16 +0300 |
---|---|---|
committer | Maxim Filippov <colixer@gmail.com> | 2019-08-27 20:48:16 +0300 |
commit | 5e4fde1d3d49ec56fae3b199fb4af51057e2dffd (patch) | |
tree | 3e9bd7d4edd147dd11b4d2ef2165ae4e62a827bb /test | |
parent | ba5e14be05c78a8905747d7c9930b3b23a9bdb18 (diff) | |
download | pleroma-5e4fde1d3d49ec56fae3b199fb4af51057e2dffd.tar.gz |
Filter logs by date
Diffstat (limited to 'test')
-rw-r--r-- | test/web/admin_api/admin_api_controller_test.exs | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/test/web/admin_api/admin_api_controller_test.exs b/test/web/admin_api/admin_api_controller_test.exs index 4e2c27431..a7269aee9 100644 --- a/test/web/admin_api/admin_api_controller_test.exs +++ b/test/web/admin_api/admin_api_controller_test.exs @@ -2348,6 +2348,52 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do assert second_entry["message"] == "@#{admin.nickname} followed relay: https://example.org/relay" end + + test "filters log by date", %{conn: conn, admin: admin} do + first_date = "2017-08-15T15:47:06Z" + second_date = "2017-08-20T15:47:06Z" + + Repo.insert(%ModerationLog{ + data: %{ + actor: %{ + "id" => admin.id, + "nickname" => admin.nickname, + "type" => "user" + }, + action: "relay_follow", + target: "https://example.org/relay" + }, + inserted_at: NaiveDateTime.from_iso8601!(first_date) + }) + + Repo.insert(%ModerationLog{ + data: %{ + actor: %{ + "id" => admin.id, + "nickname" => admin.nickname, + "type" => "user" + }, + action: "relay_unfollow", + target: "https://example.org/relay" + }, + inserted_at: NaiveDateTime.from_iso8601!(second_date) + }) + + conn1 = + get( + conn, + "/api/pleroma/admin/moderation_log?start_date=#{second_date}" + ) + + response1 = json_response(conn1, 200) + [first_entry] = response1 + + assert response1 |> length() == 1 + assert first_entry["data"]["action"] == "relay_unfollow" + + assert first_entry["message"] == + "@#{admin.nickname} unfollowed relay: https://example.org/relay" + end end end |