diff --git a/app/models/issue.rb b/app/models/issue.rb index 8c8947bac..bd58e7e96 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -120,7 +120,7 @@ class Issue < ActiveRecord::Base :update_parent_attributes, :delete_selected_attachments, :create_journal # Should be after_create but would be called before previous after_save callbacks after_save :after_create_from_copy - after_destroy :update_parent_attributes + after_destroy :update_parent_attributes, :log_issue_deletion # add_auto_watcher needs to run before sending notifications, thus it needs # to be added after send_notification (after_ callbacks are run in inverse order) # https://api.rubyonrails.org/v5.2.3/classes/ActiveSupport/Callbacks/ClassMethods.html#method-i-set_callback @@ -2095,4 +2095,9 @@ class Issue < ActiveRecord::Base roles = user.admin ? Role.all.to_a : user.roles_for_project(project) roles.select(&:consider_workflow?) end + + def log_issue_deletion + user = User.current + Rails.logger.info "Deleted issue: '#{self}' by #{user}" + end end diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb index 14124f7bd..08418e5f4 100644 --- a/test/unit/issue_test.rb +++ b/test/unit/issue_test.rb @@ -2149,7 +2149,9 @@ class IssueTest < ActiveSupport::TestCase end def test_issue_destroy - Issue.find(1).destroy + issue = Issue.find(1) + Rails.logger.expects(:info).with("Deleted issue: '#{issue}' by #{User.current}") + issue.destroy assert_nil Issue.find_by_id(1) assert_nil TimeEntry.find_by_issue_id(1) end