Commit 26a98194 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'bugfix/systemhook' into 'master'

Fix bug when system hook for create deploy key

Closes #29175

See merge request !9796
parents 2cdfbbfc 0de8dccd
......@@ -24,10 +24,9 @@ class SystemHooksService
key: model.key,
id: model.id
)
if model.user
data.merge!(
username: model.user.username
)
data[:username] = model.user.username
end
when Project
data.merge!(project_data(model))
......@@ -35,8 +34,6 @@ class SystemHooksService
if event == :rename || event == :transfer
data[:old_path_with_namespace] = model.old_path_with_namespace
end
data
when User
data.merge!({
name: model.name,
......@@ -59,6 +56,8 @@ class SystemHooksService
when GroupMember
data.merge!(group_member_data(model))
end
data
end
def build_event_name(model, event)
......
---
title: Fix bug when system hook for deploy key
merge_request: 9796
author: billy.lb
......@@ -5,6 +5,7 @@ describe SystemHooksService, services: true do
let(:project) { create :project }
let(:project_member) { create :project_member }
let(:key) { create(:key, user: user) }
let(:deploy_key) { create(:key) }
let(:group) { create(:group) }
let(:group_member) { create(:group_member) }
......@@ -18,6 +19,8 @@ describe SystemHooksService, services: true do
it { expect(event_data(project_member, :destroy)).to include(:event_name, :created_at, :updated_at, :project_name, :project_path, :project_path_with_namespace, :project_id, :user_name, :user_username, :user_email, :user_id, :access_level, :project_visibility) }
it { expect(event_data(key, :create)).to include(:username, :key, :id) }
it { expect(event_data(key, :destroy)).to include(:username, :key, :id) }
it { expect(event_data(deploy_key, :create)).to include(:key, :id) }
it { expect(event_data(deploy_key, :destroy)).to include(:key, :id) }
it do
project.old_path_with_namespace = 'renamed_from_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