blob: e2a4fb3136189b974a8cfcc7cfc54d8b24275c8b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# frozen_string_literal: true
# Requires a context containing:
# - subject
# - action
# - user
# Optionally, the context can contain:
# - project
# - namespace
RSpec.shared_examples 'internal event tracking' do
let(:fake_tracker) { instance_spy(Gitlab::Tracking::Destinations::Snowplow) }
let(:namespace) { nil }
let(:proejct) { nil }
before do
allow(Gitlab::Tracking).to receive(:tracker).and_return(fake_tracker)
allow(Gitlab::Tracking::StandardContext).to receive(:new).and_call_original
allow(Gitlab::Tracking::ServicePingContext).to receive(:new).and_call_original
end
it 'logs to Snowplow', :aggregate_failures do
subject
expect(Gitlab::Tracking::StandardContext)
.to have_received(:new)
.with(
project_id: project&.id,
user_id: user.id,
namespace_id: namespace&.id,
plan_name: namespace&.actual_plan_name
)
expect(Gitlab::Tracking::ServicePingContext)
.to have_received(:new)
.with(data_source: :redis_hll, event: action)
expect(fake_tracker).to have_received(:event)
.with(
'InternalEventTracking',
action,
context: [
an_instance_of(SnowplowTracker::SelfDescribingJson),
an_instance_of(SnowplowTracker::SelfDescribingJson)
]
)
.exactly(:once)
end
end
|