blob: 7e5a225f02096e82035fc92c71e8313cfcede253 (
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
|
# frozen_string_literal: true
RSpec.shared_examples 'tracking unique hll events' do |feature_flag|
context 'when format is HTML' do
let(:format) { :html }
it 'tracks unique event' do
expect(Gitlab::UsageDataCounters::HLLRedisCounter).to receive(:track_event).with(expected_type, target_id)
subject
end
it 'tracks unique event if DNT is not enabled' do
expect(Gitlab::UsageDataCounters::HLLRedisCounter).to receive(:track_event).with(expected_type, target_id)
request.headers['DNT'] = '0'
subject
end
it 'does not track unique event if DNT is enabled' do
expect(Gitlab::UsageDataCounters::HLLRedisCounter).not_to receive(:track_event).with(expected_type, target_id)
request.headers['DNT'] = '1'
subject
end
context 'when feature flag is disabled' do
it 'does not track unique event' do
stub_feature_flags(feature_flag => false)
expect(Gitlab::UsageDataCounters::HLLRedisCounter).not_to receive(:track_event).with(expected_type, target_id)
subject
end
end
end
context 'when format is JSON' do
let(:format) { :json }
it 'does not track unique event if the format is JSON' do
expect(Gitlab::UsageDataCounters::HLLRedisCounter).not_to receive(:track_event).with(expected_type, target_id)
subject
end
end
end
|