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

@@ -141,7 +141,9 @@ class CommentsControllerTest < ActionDispatch::IntegrationTest
context "when updating another user's comment" do
should "succeed if updater is a moderator" do
put_auth comment_path(@comment.id), @user, params: {comment: {body: "abc"}}, xhr: true
assert_equal("abc", @comment.reload.body)
assert_match(/updated comment ##{@comment.id}/, ModAction.last.description)
assert_response :success
end
@@ -156,7 +158,9 @@ class CommentsControllerTest < ActionDispatch::IntegrationTest
context "when stickying a comment" do
should "succeed if updater is a moderator" do
put_auth comment_path(@comment.id), @mod, params: {comment: {is_sticky: true}}, xhr: true
assert_equal(true, @comment.reload.is_sticky)
assert_match(/updated comment ##{@comment.id}/, ModAction.last.description)
assert_response :success
end
@@ -179,14 +183,18 @@ class CommentsControllerTest < ActionDispatch::IntegrationTest
should "update the body" do
put_auth comment_path(@comment.id), @user, params: {comment: {body: "abc"}}, xhr: true
assert_equal("abc", @comment.reload.body)
assert_match(/updated comment ##{@comment.id}/, ModAction.last.description)
assert_response :success
end
should "allow changing the body and is_deleted" do
put_auth comment_path(@comment.id), @user, params: {comment: {body: "herp derp", is_deleted: true}}, xhr: true
assert_equal("herp derp", @comment.reload.body)
assert_equal(true, @comment.is_deleted)
assert_match(/deleted comment ##{@comment.id}/, ModAction.last.description)
assert_response :success
end
@@ -240,6 +248,7 @@ class CommentsControllerTest < ActionDispatch::IntegrationTest
assert_equal(true, @comment.reload.is_deleted)
assert_redirected_to @comment
assert_match(/deleted comment ##{@comment.id}/, ModAction.last.description)
end
should "mark all pending moderation reports against the comment as handled" do
@@ -263,6 +272,7 @@ class CommentsControllerTest < ActionDispatch::IntegrationTest
assert_redirected_to(@comment)
assert_equal(false, @comment.reload.is_deleted)
assert_match(/updated comment ##{@comment.id}/, ModAction.last.description)
end
should "not allow normal Members to undelete their own comments" do