Commit 747e5c3b authored by James Lopez's avatar James Lopez

use request to pass extra parameters

parent 6a2737e6
......@@ -17,7 +17,7 @@ class AnalyticsGenericEntity < Grape::Entity
end
expose :url do |object|
url_to("namespace_project_#{object[:entity]}".to_sym, id: object[:iid].to_s)
url_to("namespace_project_#{request.entity}".to_sym, id: object[:iid].to_s)
end
private
......
......@@ -49,10 +49,10 @@ module Gitlab
private
def parse_event(event)
def parse_event(event, entity: :issue)
event['author'] = User.find(event.remove('author_id'))
AnalyticsGenericSerializer.new(project: @project).represent(event).as_json
AnalyticsGenericSerializer.new(project: @project, entity: entity).represent(event).as_json
end
def parse_build_event(event)
......
......@@ -10,14 +10,14 @@ describe AnalyticsGenericEntity do
id: "1",
created_at: "2016-11-12 15:04:02.948604",
author: user,
entity: :merge_request
}
}
let(:project) { create(:empty_project) }
let(:request) { EntityRequest.new(project: project, entity: :merge_request) }
let(:entity) do
described_class.new(entity_hash, request: double, project: project)
described_class.new(entity_hash, request: request, project: project)
end
context 'generic entity' do
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe AnalyticsGenericSerializer do
let(:serializer) do
described_class
.new(project: project)
.new(project: project, entity: :merge_request)
.represent(resource)
end
......@@ -18,7 +18,6 @@ describe AnalyticsGenericSerializer do
id: "1",
created_at: "2016-11-12 15:04:02.948604",
author: user,
entity: :merge_request
}
}
......
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