Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/controllers/concerns/redis_tracking_spec.rb')
-rw-r--r--spec/controllers/concerns/redis_tracking_spec.rb32
1 files changed, 23 insertions, 9 deletions
diff --git a/spec/controllers/concerns/redis_tracking_spec.rb b/spec/controllers/concerns/redis_tracking_spec.rb
index 53b49dd30a6..4077f4f5cce 100644
--- a/spec/controllers/concerns/redis_tracking_spec.rb
+++ b/spec/controllers/concerns/redis_tracking_spec.rb
@@ -9,8 +9,8 @@ RSpec.describe RedisTracking do
include RedisTracking
skip_before_action :authenticate_user!, only: :show
- track_redis_hll_event :index, :show, name: 'g_compliance_approval_rules',
- if: [:custom_condition_one?, :custom_condition_two?]
+ track_redis_hll_event(:index, :show, name: 'g_compliance_approval_rules',
+ if: [:custom_condition_one?, :custom_condition_two?]) { |controller| controller.get_custom_id }
def index
render html: 'index'
@@ -24,6 +24,10 @@ RSpec.describe RedisTracking do
render html: 'show'
end
+ def get_custom_id
+ 'some_custom_id'
+ end
+
private
def custom_condition_one?
@@ -92,19 +96,15 @@ RSpec.describe RedisTracking do
end
end
- context 'when user is not logged in and there is a visitor_id' do
+ context 'when user is not logged in' do
let(:visitor_id) { SecureRandom.uuid }
- before do
- routes.draw { get 'show' => 'anonymous#show' }
- end
-
- it 'tracks the event' do
+ it 'tracks the event when there is a visitor id' do
cookies[:visitor_id] = { value: visitor_id, expires: 24.months }
expect_tracking
- get :show
+ get :show, params: { id: 1 }
end
end
@@ -114,5 +114,19 @@ RSpec.describe RedisTracking do
get :index
end
+
+ it 'tracks the event when there is custom id' do
+ expect_tracking
+
+ get :show, params: { id: 1 }
+ end
+
+ it 'does not track the event when there is no custom id' do
+ expect(controller).to receive(:get_custom_id).and_return(nil)
+
+ expect_no_tracking
+
+ get :show, params: { id: 2 }
+ end
end
end