mod actions: fix messages to use consistent format.

Fix mod actions to use the same message format everywhere.

Before mod actions were formatted in various inconsistent ways:

* "deleted post #1234"
* "comment #1234 updated by <user>"
* "<user> updated forum #1234"
* "<user> level changed Member -> Builder"

Now all mod actions consistently use this format:

* "deleted post #1234"
* "updated comment #1234"
* "updated forum #1234"
* "promoted <user> from Member to Builder"

This way mod actions are formatted consistently with other actions on
the /user_actions page, where everything is written as "<user> did X".

Also add a fix script to fix existing mod actions.
This commit is contained in:
evazion
2022-09-18 20:30:41 -05:00
parent 72e95b6ca3
commit 2119a8efc5
21 changed files with 224 additions and 33 deletions

View File

@@ -18,13 +18,16 @@ class IpBansControllerTest < ActionDispatch::IntegrationTest
should "create a new ip ban" do
assert_difference("IpBan.count", 1) do
post_auth ip_bans_path, @admin, params: {:ip_ban => {:ip_addr => "1.2.3.4", :reason => "xyz"}}
assert_response :redirect
end
end
should "log a mod action" do
post_auth ip_bans_path, @admin, params: { ip_ban: { ip_addr: "1.2.3.4", reason: "xyz" }}
assert_equal("ip_ban_create", ModAction.last&.category)
assert_match(/created ip ban for 1\.2\.3\.4/, ModAction.last.description)
end
end
@@ -61,6 +64,17 @@ class IpBansControllerTest < ActionDispatch::IntegrationTest
assert_response :success
assert_equal(true, @ip_ban.reload.is_deleted)
assert_equal("ip_ban_delete", ModAction.last.category)
assert_match(/deleted ip ban for #{@ip_ban.ip_addr}/, ModAction.last.description)
end
should "mark an ip ban as undeleted" do
@ip_ban = create(:ip_ban, ip_addr: "5.6.7.8", is_deleted: true)
put_auth ip_ban_path(@ip_ban), @admin, params: { ip_ban: { is_deleted: false }, format: "js" }
assert_response :success
assert_equal(false, @ip_ban.reload.is_deleted?)
assert_equal("ip_ban_undelete", ModAction.last.category)
assert_match(/undeleted ip ban for #{@ip_ban.ip_addr}/, ModAction.last.description)
end
end
end