Don't error out in system hook if user has `nil` datetime columns
Deleting a user would fail in the system hooks if the user had `nil` column in `datetime` or `updated_at` fields. Closes #43871
This commit is contained in:
parent
8a0052c037
commit
2d1ceca077
|
@ -20,8 +20,8 @@ class SystemHooksService
|
|||
def build_event_data(model, event)
|
||||
data = {
|
||||
event_name: build_event_name(model, event),
|
||||
created_at: model.created_at.xmlschema,
|
||||
updated_at: model.updated_at.xmlschema
|
||||
created_at: model.created_at&.xmlschema,
|
||||
updated_at: model.updated_at&.xmlschema
|
||||
}
|
||||
|
||||
case model
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Don't error out in system hook if user has `nil` datetime columns
|
||||
merge_request:
|
||||
author:
|
||||
type: fixed
|
|
@ -70,6 +70,14 @@ describe SystemHooksService do
|
|||
expect(data[:project_visibility]).to eq('private')
|
||||
end
|
||||
|
||||
it 'handles nil datetime columns' do
|
||||
user.update_attributes(created_at: nil, updated_at: nil)
|
||||
data = event_data(user, :destroy)
|
||||
|
||||
expect(data[:created_at]).to be(nil)
|
||||
expect(data[:updated_at]).to be(nil)
|
||||
end
|
||||
|
||||
context 'group_rename' do
|
||||
it 'contains old and new path' do
|
||||
allow(group).to receive(:path_was).and_return('old-path')
|
||||
|
|
Loading…
Reference in New Issue