summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Provaznik <jprovaznik@gitlab.com>2019-09-03 13:20:15 +0200
committerJan Provaznik <jprovaznik@gitlab.com>2019-09-03 20:38:50 +0200
commit50987fd52ee309f15fa278e014d47dbdea67fca7 (patch)
tree9ff28e55c764f677ab61bc304510bdd5aaf635e0
parenta97278864a1ce0b0bf68edd3150c062d9f48bbf9 (diff)
downloadgitlab-ce-epic-events.tar.gz
Check resource_parent explicitlyepic-events
-rw-r--r--app/services/event_create_service.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/app/services/event_create_service.rb b/app/services/event_create_service.rb
index 925a174c1e9..39266a6c961 100644
--- a/app/services/event_create_service.rb
+++ b/app/services/event_create_service.rb
@@ -99,14 +99,19 @@ class EventCreateService
end
def create_event(resource_parent, current_user, status, attributes = {})
- resource_parent_attr = resource_parent.is_a?(Project) ? :project : :group
-
attributes.reverse_merge!(
- resource_parent_attr => resource_parent,
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