diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-03-21 07:04:03 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-03-21 07:04:03 +0300 |
commit | 26a981940cc5fcb48bf11bdd29347cdb2657e2f6 (patch) | |
tree | ce1d83a528417bb82d70ee3cf833cfbbb917b130 | |
parent | 2cdfbbfc2f4b6e7627d1be43635bba64d082e803 (diff) | |
parent | 0de8dccd2a7a5e07805fe6c151e44cf4ad3bf86f (diff) |
Merge branch 'bugfix/systemhook' into 'master'
Fix bug when system hook for create deploy key
Closes #29175
See merge request !9796
-rw-r--r-- | app/services/system_hooks_service.rb | 9 | ||||
-rw-r--r-- | changelogs/unreleased/bugfix-systemhook.yml | 4 | ||||
-rw-r--r-- | spec/services/system_hooks_service_spec.rb | 3 |
3 files changed, 11 insertions, 5 deletions
diff --git a/app/services/system_hooks_service.rb b/app/services/system_hooks_service.rb index 868fa7b3f21..af0ddbe5934 100644 --- a/app/services/system_hooks_service.rb +++ b/app/services/system_hooks_service.rb @@ -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) diff --git a/changelogs/unreleased/bugfix-systemhook.yml b/changelogs/unreleased/bugfix-systemhook.yml new file mode 100644 index 00000000000..4c4d0dcc7a2 --- /dev/null +++ b/changelogs/unreleased/bugfix-systemhook.yml @@ -0,0 +1,4 @@ +--- +title: Fix bug when system hook for deploy key +merge_request: 9796 +author: billy.lb diff --git a/spec/services/system_hooks_service_spec.rb b/spec/services/system_hooks_service_spec.rb index db9f1231682..11037a4917b 100644 --- a/spec/services/system_hooks_service_spec.rb +++ b/spec/services/system_hooks_service_spec.rb @@ -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' |