Commit 269d158b authored by Kev's avatar Kev Committed by Rémy Coutable

Fix RSpec/TimecopFreeze offenses (Part 1/2)

Changelog: other
parent 2f33a8cb
---
RSpec/TimecopFreeze:
Exclude:
- ee/spec/lib/gitlab/analytics/cycle_analytics/data_collector_spec.rb
- ee/spec/lib/gitlab/insights/reducers/count_per_period_reducer_spec.rb
- ee/spec/models/merge_train_spec.rb
- ee/spec/support/shared_contexts/lib/gitlab/insights/reducers/reducers_shared_contexts.rb
- qa/spec/support/repeater_spec.rb
......
......@@ -12,7 +12,9 @@ RSpec.describe Gitlab::Analytics::CycleAnalytics::DataCollector do
end
around do |example|
Timecop.freeze(current_time) { example.run }
travel_to(current_time)
example.run
travel_back
end
def round_to_days(seconds)
......@@ -596,13 +598,13 @@ RSpec.describe Gitlab::Analytics::CycleAnalytics::DataCollector do
before do
group.add_user(user, GroupMember::MAINTAINER)
travel_to(Time.new(2019, 6, 1)) do
mr = create(:merge_request, source_project: project1)
mr.metrics.update!(merged_at: 1.hour.from_now)
travel_to(Time.new(2019, 6, 1))
mr = create(:merge_request, source_project: project1)
mr.metrics.update!(merged_at: 1.hour.from_now)
mr = create(:merge_request, source_project: project2)
mr.metrics.update!(merged_at: 1.hour.from_now)
end
mr = create(:merge_request, source_project: project2)
mr.metrics.update!(merged_at: 1.hour.from_now)
travel_back
end
shared_examples 'filter examples' do
......
......@@ -26,7 +26,7 @@ RSpec.describe Gitlab::Insights::Reducers::CountPerPeriodReducer do
context 'with no issues' do
around do |example|
Timecop.freeze(Time.utc(2019, 5, 5)) { example.run }
travel_to(Time.utc(2019, 5, 5)) { example.run }
end
let(:project) { create(:project, :public) }
......@@ -144,7 +144,7 @@ RSpec.describe Gitlab::Insights::Reducers::CountPerPeriodReducer do
merge_request = public_send("issuable#{i}")
merge_request_metrics_service = MergeRequestMetricsService.new(merge_request.metrics)
Event.transaction do
Timecop.freeze(merge_request.created_at) do
travel_to(merge_request.created_at) do
merge_event = EventCreateService.new.merge_mr(merge_request, merge_request.author)
merge_request_metrics_service.merge(merge_event)
end
......
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