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

@@ -19,8 +19,10 @@ class Admin::UsersControllerTest < ActionDispatch::IntegrationTest
context "on a basic user" do
should "succeed" do
put_auth admin_user_path(@user), @mod, params: {:user => {:level => "30"}}
assert_redirected_to(edit_admin_user_path(@user))
assert_equal(30, @user.reload.level)
assert_match(/promoted "#{@user.name}":\/users\/#{@user.id} from Member to Gold/, ModAction.last.description)
end
should "promote the user to unrestricted uploads" do
@@ -30,6 +32,8 @@ class Admin::UsersControllerTest < ActionDispatch::IntegrationTest
assert_equal(true, @user.is_builder?)
assert_equal(true, @user.can_upload_free?)
assert_equal(false, @user.can_approve_posts?)
assert_match(/granted unlimited upload privileges to "#{@user.name}":\/users\/#{@user.id}/, ModAction.first.description)
assert_match(/promoted "#{@user.name}":\/users\/#{@user.id} from Member to Builder/, ModAction.last.description)
end
should "promote the user to approver" do
@@ -39,6 +43,8 @@ class Admin::UsersControllerTest < ActionDispatch::IntegrationTest
assert_equal(true, @user.is_builder?)
assert_equal(false, @user.can_upload_free?)
assert_equal(true, @user.can_approve_posts?)
assert_match(/granted approval privileges to "#{@user.name}":\/users\/#{@user.id}/, ModAction.first.description)
assert_match(/promoted "#{@user.name}":\/users\/#{@user.id} from Member to Builder/, ModAction.last.description)
end
context "promoted to an admin" do