Add /user_actions page.

Add a /user_actions page. This page shows you a global timeline of
(almost) all activity on the site, including uploads, comments, votes,
edits, forum posts, and so on.

The main things it doesn't include are post edits, pool edits, and
favorites (posts and pools live in a separate database, and favorites
don't have the timestamps we need for ordering).

This page is useful for moderation purposes because it lets you see a
history of almost all of a user's activity on a single page.

Currently this page is mod-only. In the future it will be open to all
users, so you can view the history of your own site activity, or the
activity of others.
This commit is contained in:
evazion
2022-09-14 16:30:46 -05:00
parent 0830af49a7
commit ee638f976f
22 changed files with 462 additions and 7 deletions

View File

@@ -3,5 +3,6 @@ FactoryBot.define do
creator
reason {"xxx"}
status { :pending }
model { build(:comment) }
end
end

View File

@@ -2,5 +2,6 @@ FactoryBot.define do
factory(:user_event) do
user
user_session
category { :login }
end
end

View File

@@ -0,0 +1,72 @@
require 'test_helper'
class UserActionsControllerTest < ActionDispatch::IntegrationTest
context "The user actions controller" do
context "index action" do
setup do
@user = create(:user)
as(@user) do
create(:artist)
create(:artist_commentary)
create(:ban)
create(:bulk_update_request)
create(:comment)
create(:comment_vote)
create(:dmail)
create(:favorite_group)
create(:forum_post)
create(:forum_post_vote)
create(:forum_topic)
create(:mod_action)
create(:moderation_report)
create(:note)
create(:post)
create(:post_appeal)
create(:post_approval)
create(:post_disapproval)
create(:post_flag)
create(:post_replacement)
create(:post_vote)
create(:wiki_page)
create(:saved_search)
create(:tag)
create(:tag_alias)
create(:tag_implication)
create(:upload)
create(:user_event)
create(:user_feedback)
create(:user_name_change_request)
create(:user_upgrade)
create(:wiki_page)
end
end
should "render for the owner" do
get_auth user_events_path(limit: 1000), create(:admin_user)
assert_response :success
end
should "render for an admin" do
get_auth user_events_path(limit: 1000), create(:admin_user)
assert_response :success
end
should "render for a mod" do
get_auth user_events_path(limit: 1000), create(:moderator_user)
assert_response :success
end
should "fail for a normal user" do
get_auth user_actions_path(limit: 1000), create(:user)
assert_response 403
end
should "render when filtering on a single user" do
get_auth user_events_path(user_id: @user.id, limit: 1000), create(:owner_user)
assert_response :success
end
end
end
end