Feature #39774 ยป add_logging_for_issue_deletion.patch
| app/models/issue.rb | ||
|---|---|---|
|
: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
|
||
| ... | ... | |
|
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
|
||
| test/unit/issue_test.rb | ||
|---|---|---|
|
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
|
||