BigW Consortium Gitlab

Commit 4ac0a4bf by Robert Speicher

Merge branch 'sh-fix-issue-43871-system-hooks' into 'master'

Don't error out in system hook if user has `nil` datetime columns Closes #43871 See merge request gitlab-org/gitlab-ce!17543
parents 6ec655f5 2d1ceca0
......@@ -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
......
---
title: Don't error out in system hook if user has `nil` datetime columns
merge_request:
author:
type: fixed
......@@ -74,6 +74,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')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment