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