Skip to content
Snippets Groups Projects
Commit b900c40f authored by Niko Belokolodov's avatar Niko Belokolodov :two: Committed by Allen Cook
Browse files

Resolve "Refactor Snowplow tracking specs"

parent e7c88821
No related branches found
No related tags found
1 merge request!100994Resolve "Refactor Snowplow tracking specs"
......@@ -51,11 +51,9 @@ def custom_condition_two?
end
end
def expect_tracking(user: self.user)
def expect_redis_hll_tracking
expect(Gitlab::UsageDataCounters::HLLRedisCounter).to have_received(:track_event)
.with('g_analytics_valuestream', values: instance_of(String))
expect_snowplow_tracking(user)
end
def expect_snowplow_tracking(user)
......@@ -85,7 +83,8 @@ def expect_no_tracking
it 'tracks the event' do
get :index
expect_tracking
expect_redis_hll_tracking
expect_snowplow_tracking(user)
end
context 'when FF is disabled' do
......@@ -105,7 +104,8 @@ def expect_no_tracking
get :index
expect_tracking
expect_redis_hll_tracking
expect_snowplow_tracking(user)
end
it 'does not track the event if DNT is enabled' do
......@@ -145,7 +145,8 @@ def expect_no_tracking
get :show, params: { id: 1 }
expect_tracking(user: nil)
expect_redis_hll_tracking
expect_snowplow_tracking(nil)
end
end
......@@ -159,16 +160,24 @@ def expect_no_tracking
it 'tracks the event when there is custom id' do
get :show, params: { id: 1 }
expect_tracking(user: nil)
expect_redis_hll_tracking
expect_snowplow_tracking(nil)
end
it 'does not track the HLL event when there is no custom id' do
allow(controller).to receive(:get_custom_id).and_return(nil)
context 'when there is no custom_id set' do
before do
allow(controller).to receive(:get_custom_id).and_return(nil)
get :show, params: { id: 2 }
get :show, params: { id: 2 }
end
expect(Gitlab::UsageDataCounters::HLLRedisCounter).not_to receive(:track_event)
expect_snowplow_tracking(nil)
it 'does not track the HLL event' do
expect(Gitlab::UsageDataCounters::HLLRedisCounter).not_to receive(:track_event)
end
it 'tracks Snowplow event' do
expect_snowplow_tracking(nil)
end
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment