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

@@ -100,6 +100,7 @@ class UserFeedbacksControllerTest < ActionDispatch::IntegrationTest
assert_redirected_to(@user_feedback)
assert_equal("positive", @user_feedback.reload.category)
assert_equal(0, ModAction.count)
end
should "not allow updating deleted feedbacks" do
@@ -114,14 +115,24 @@ class UserFeedbacksControllerTest < ActionDispatch::IntegrationTest
assert_response :redirect
assert_equal(true, @user_feedback.reload.is_deleted)
assert_equal(0, ModAction.count)
end
context "by a moderator" do
should "allow updating feedbacks given to other users" do
put_auth user_feedback_path(@user_feedback), @mod, params: { user_feedback: { body: "blah" }}
assert_redirected_to @user_feedback
assert_equal("blah", @user_feedback.reload.body)
assert_match(/updated user feedback for "#{@user.name}":\/users\/#{@user.id}/, ModAction.last.description)
end
should "allow deleting feedbacks given to other users" do
put_auth user_feedback_path(@user_feedback), @mod, params: { user_feedback: { is_deleted: "true" }}
assert_redirected_to @user_feedback
assert(@user_feedback.reload.is_deleted?)
assert_match(/updated user feedback for "#{@user.name}":\/users\/#{@user.id}/, ModAction.last.description)
end
should "not allow updating feedbacks given to themselves" do