Skip to content

Commit 8650e54

Browse files
committed
ensured proper audit logs when lifting warnings / suspensions
1 parent 3a6b17f commit 8650e54

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

app/controllers/mod_warning_controller.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@ def lift
7070
@warning.update(active: false, read: false)
7171
@user.community_user.update is_suspended: false, suspension_public_comment: nil, suspension_end: nil
7272

73-
audit_warning('suspension_lift', @warning)
73+
audit_warning('warning_lift', @warning)
74+
75+
if @warning.suspension?
76+
audit_warning('suspension_lift', @warning)
77+
end
7478

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

app/models/mod_warning.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,16 @@ class ModWarning < ApplicationRecord
1010
scope :active, -> { where(active: true) }
1111
scope :to, ->(user) { where(community_user: user.community_user) }
1212

13+
# Was the warning issued with a suspension?
14+
# @return [Boolean] check result
15+
def suspension?
16+
is_suspension
17+
end
18+
19+
# Is the suspension issued with the warning still active?
20+
# @return [Boolean] check result
1321
def suspension_active?
14-
active && is_suspension && !suspension_end.past?
22+
active && suspension? && !suspension_end.past?
1523
end
1624

1725
def body_as_html

test/controllers/mod_warning_controller_test.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ class ModWarningControllerTest < ActionController::TestCase
9797
assert_response(:found)
9898
warning.reload
9999
assert_not warning.active
100+
101+
assert_audit_log('warning_lift', related: warning)
102+
assert_audit_log('suspension_lift', related: warning)
100103
end
101104

102105
private

0 commit comments

Comments
 (0)