Skip to content

Commit 65723b5

Browse files
committed
creating a mod warning with suspension should create a separate suspension_create audit log
1 parent a74b2a5 commit 65723b5

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

app/controllers/mod_warning_controller.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,15 @@ def create
4646
@warning = ModWarning.new(author: current_user, community_user: @user.community_user,
4747
body: params[:mod_warning][:body], is_suspension: is_suspension,
4848
suspension_end: suspension_end, active: true, read: false)
49+
4950
if @warning.save
5051
audit_warning('warning_create', @warning)
5152

5253
if is_suspension
5354
@user.community_user.update(is_suspended: is_suspension, suspension_end: suspension_end,
5455
suspension_public_comment: params[:mod_warning][:suspension_public_notice])
56+
57+
audit_warning('suspension_create', @warning)
5558
end
5659

5760
redirect_to user_path(@user)
@@ -67,7 +70,7 @@ def lift
6770
@warning.update(active: false, read: false)
6871
@user.community_user.update is_suspended: false, suspension_public_comment: nil, suspension_end: nil
6972

70-
audit_warning('warning_lift', @warning)
73+
audit_warning('suspension_lift', @warning)
7174

7275
flash[:success] = 'The warning or suspension has been lifted. Please consider adding an annotation ' \
7376
'explaining your reasons.'

test/controllers/mod_warning_controller_test.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class ModWarningControllerTest < ActionController::TestCase
3030
end
3131
end
3232

33-
test ':create should correclty create mod warnings' do
33+
test ':create should correctly create mod warnings' do
3434
user = users(:moderator)
3535
subject = users(:standard_user)
3636

@@ -42,6 +42,7 @@ class ModWarningControllerTest < ActionController::TestCase
4242
warning = assigns(:warning)
4343
assert_not_nil warning
4444
assert_audit_log('warning_create', related: warning)
45+
assert_audit_log('suspension_create', related: warning)
4546
end
4647

4748
test 'suspended user should redirect to current warning page' do

0 commit comments

Comments
 (0)