mod actions: record the subject of the mod action.
Add a polymorphic `subject` field that records the subject of the mod action. The subject is the post, user, comment, artist, etc the mod action is for. * The subject for the user ban and unban actions is the user, not the ban itself. * The subject for the user feedback update and deletion actions is the user, not the feedback itself. * The subject for the post undeletion action is the post, not the approval itself. * The subject for the move favorites action is the source post where the favorites were moved from, not the destination post where the favorites were moved to. * The subject for the post permanent delete action is nil, because the post itself is hard deleted. * When a post is permanently deleted, all mod actions related to the post are deleted as well.
This commit is contained in:
@@ -23,6 +23,8 @@ class Admin::UsersControllerTest < ActionDispatch::IntegrationTest
|
||||
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)
|
||||
assert_equal(@user, ModAction.last.subject)
|
||||
assert_equal(@mod, ModAction.last.creator)
|
||||
end
|
||||
|
||||
should "promote the user to unrestricted uploads" do
|
||||
@@ -34,6 +36,10 @@ class Admin::UsersControllerTest < ActionDispatch::IntegrationTest
|
||||
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)
|
||||
assert_equal(@user, ModAction.first.subject)
|
||||
assert_equal(@mod, ModAction.first.creator)
|
||||
assert_equal(@user, ModAction.last.subject)
|
||||
assert_equal(@mod, ModAction.last.creator)
|
||||
end
|
||||
|
||||
should "promote the user to approver" do
|
||||
@@ -45,6 +51,10 @@ class Admin::UsersControllerTest < ActionDispatch::IntegrationTest
|
||||
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)
|
||||
assert_equal(@user, ModAction.first.subject)
|
||||
assert_equal(@mod, ModAction.first.creator)
|
||||
assert_equal(@user, ModAction.last.subject)
|
||||
assert_equal(@mod, ModAction.last.creator)
|
||||
end
|
||||
|
||||
context "promoted to an admin" do
|
||||
|
||||
Reference in New Issue
Block a user