summaryrefslogtreecommitdiff
path: root/app/services
diff options
context:
space:
mode:
authorJan Provaznik <jprovaznik@gitlab.com>2019-09-03 21:29:55 +0000
committerThong Kuah <tkuah@gitlab.com>2019-09-03 21:29:55 +0000
commit243bd0202fe3373a997f5ed37c027ab8cfdfcb35 (patch)
treeb57dd84260e2ea26f3c39aaf8310f3e2625df9f7 /app/services
parent7bf4ef502612c523dc993e35e1ed36fa2ea7364f (diff)
downloadgitlab-ce-243bd0202fe3373a997f5ed37c027ab8cfdfcb35.tar.gz
Create an event on epic actions
Creates new event when an epic is created, closed, reopened or commented.
Diffstat (limited to 'app/services')
-rw-r--r--app/services/event_create_service.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/app/services/event_create_service.rb b/app/services/event_create_service.rb
index e7464fd9d5f..39266a6c961 100644
--- a/app/services/event_create_service.rb
+++ b/app/services/event_create_service.rb
@@ -95,16 +95,23 @@ class EventCreateService
private
def create_record_event(record, current_user, status)
- create_event(record.project, current_user, status, target_id: record.id, target_type: record.class.name)
+ create_event(record.resource_parent, current_user, status, target_id: record.id, target_type: record.class.name)
end
- def create_event(project, current_user, status, attributes = {})
+ def create_event(resource_parent, current_user, status, attributes = {})
attributes.reverse_merge!(
- project: project,
action: status,
author_id: current_user.id
)
+ resource_parent_attr = case resource_parent
+ when Project
+ :project
+ when Group
+ :group
+ end
+ attributes[resource_parent_attr] = resource_parent if resource_parent_attr
+
Event.create!(attributes)
end
end