Commit 6c43b61c authored by charlie ablett's avatar charlie ablett

Merge branch...

Merge branch '223799-analytics-unique-visitors-spec-fails-spec-lib-gitlab-analytics-unique_visits_spec-rb-14' into 'master'

Freeze time in spec/lib/gitlab/analytics/unique_visits_spec.rb

Closes #223799

See merge request gitlab-org/gitlab!35098
parents 9c7a9087 03d1a326
...@@ -10,6 +10,15 @@ describe Gitlab::Analytics::UniqueVisits, :clean_gitlab_redis_shared_state do ...@@ -10,6 +10,15 @@ describe Gitlab::Analytics::UniqueVisits, :clean_gitlab_redis_shared_state do
let(:visitor1_id) { 'dfb9d2d2-f56c-4c77-8aeb-6cddc4a1f857' } let(:visitor1_id) { 'dfb9d2d2-f56c-4c77-8aeb-6cddc4a1f857' }
let(:visitor2_id) { '1dd9afb2-a3ee-4de1-8ae3-a405579c8584' } let(:visitor2_id) { '1dd9afb2-a3ee-4de1-8ae3-a405579c8584' }
around do |example|
# We need to freeze to a reference time
# because visits are grouped by the week number in the year
# Without freezing the time, the test may behave inconsistently
# depending on which day of the week test is run.
reference_time = Time.utc(2020, 6, 1)
Timecop.freeze(reference_time) { example.run }
end
describe '#track_visit' do describe '#track_visit' do
it 'tracks the unique weekly visits for targets' do it 'tracks the unique weekly visits for targets' do
unique_visits.track_visit(visitor1_id, target1_id, 7.days.ago) unique_visits.track_visit(visitor1_id, target1_id, 7.days.ago)
......
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