mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 02:19:27 +08:00
FIX: log warning when context is missing when a user is destroyed (#12182)
This commit is contained in:
parent
1844bde57c
commit
73fa4263fb
|
@ -93,6 +93,7 @@ class UserDestroyer
|
|||
deleted_by = @actor
|
||||
end
|
||||
StaffActionLogger.new(deleted_by).log_user_deletion(user, opts.slice(:context))
|
||||
Rails.logger.warn("User destroyed without context from: #{caller_locations(14, 1)[0]}") if opts.slice(:context).blank?
|
||||
end
|
||||
MessageBus.publish "/logout", result.id, user_ids: [result.id]
|
||||
end
|
||||
|
|
|
@ -85,6 +85,15 @@ describe UserDestroyer do
|
|||
end
|
||||
end
|
||||
|
||||
context 'context is missing' do
|
||||
it "logs warning message if context is missing" do
|
||||
messages = track_log_messages(level: Logger::WARN) do
|
||||
UserDestroyer.new(admin).destroy(user)
|
||||
end
|
||||
expect(messages[0][2]).to include("User destroyed without context from:")
|
||||
end
|
||||
end
|
||||
|
||||
context "with a reviewable post" do
|
||||
let!(:reviewable) { Fabricate(:reviewable, created_by: user) }
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user