Commit 44bb86cd authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch 'ali/autocorrect-timecop-freeeze' into 'master'

[RUN AS-IF-FOSS] Run autocorrection for RSpec/TimecopFreeze in spec

See merge request gitlab-org/gitlab!40543
parents dc21b8e6 18aec09e
...@@ -44,7 +44,7 @@ RSpec.describe Projects::GraphsController do ...@@ -44,7 +44,7 @@ RSpec.describe Projects::GraphsController do
context 'when anonymous users can read build report results' do context 'when anonymous users can read build report results' do
it 'sets the daily coverage options' do it 'sets the daily coverage options' do
Timecop.freeze do freeze_time do
get(:charts, params: { namespace_id: project.namespace.path, project_id: project.path, id: 'master' }) get(:charts, params: { namespace_id: project.namespace.path, project_id: project.path, id: 'master' })
expect(assigns[:daily_coverage_options]).to eq( expect(assigns[:daily_coverage_options]).to eq(
......
...@@ -98,7 +98,7 @@ RSpec.describe Projects::NotesController do ...@@ -98,7 +98,7 @@ RSpec.describe Projects::NotesController do
let(:page_2_boundary) { microseconds(page_2.last.updated_at + NotesFinder::FETCH_OVERLAP) } let(:page_2_boundary) { microseconds(page_2.last.updated_at + NotesFinder::FETCH_OVERLAP) }
around do |example| around do |example|
Timecop.freeze do freeze_time do
example.run example.run
end end
end end
......
...@@ -23,7 +23,7 @@ RSpec.describe 'Issue Boards', :js do ...@@ -23,7 +23,7 @@ RSpec.describe 'Issue Boards', :js do
let(:application_settings) { {} } let(:application_settings) { {} }
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
before do before do
......
...@@ -8,7 +8,7 @@ RSpec.describe 'Group milestones' do ...@@ -8,7 +8,7 @@ RSpec.describe 'Group milestones' do
let_it_be(:user) { create(:group_member, :maintainer, user: create(:user), group: group ).user } let_it_be(:user) { create(:group_member, :maintainer, user: create(:user), group: group ).user }
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
before do before do
......
...@@ -112,7 +112,7 @@ RSpec.describe 'Project > Members > Invite group', :js do ...@@ -112,7 +112,7 @@ RSpec.describe 'Project > Members > Invite group', :js do
let!(:group) { create(:group) } let!(:group) { create(:group) }
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
before do before do
......
...@@ -503,7 +503,7 @@ RSpec.describe 'Login' do ...@@ -503,7 +503,7 @@ RSpec.describe 'Login' do
context 'within the grace period' do context 'within the grace period' do
it 'redirects to two-factor configuration page' do it 'redirects to two-factor configuration page' do
Timecop.freeze do freeze_time do
expect(authentication_metrics) expect(authentication_metrics)
.to increment(:user_authenticated_counter) .to increment(:user_authenticated_counter)
......
...@@ -45,7 +45,7 @@ RSpec.describe Gitlab::AlertManagement::Payload::Prometheus do ...@@ -45,7 +45,7 @@ RSpec.describe Gitlab::AlertManagement::Payload::Prometheus do
let(:current_time) { Time.current.utc } let(:current_time) { Time.current.utc }
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
subject { parsed_payload.starts_at } subject { parsed_payload.starts_at }
......
...@@ -17,7 +17,7 @@ RSpec.describe Gitlab::AppTextLogger do ...@@ -17,7 +17,7 @@ RSpec.describe Gitlab::AppTextLogger do
end end
it 'logs time in UTC with ISO8601.3 standard' do it 'logs time in UTC with ISO8601.3 standard' do
Timecop.freeze do freeze_time do
expect(subject.format_message('INFO', Time.now, nil, string_message)) expect(subject.format_message('INFO', Time.now, nil, string_message))
.to include(Time.now.utc.iso8601(3)) .to include(Time.now.utc.iso8601(3))
end end
......
...@@ -20,7 +20,7 @@ RSpec.describe Gitlab::Ci::Jwt do ...@@ -20,7 +20,7 @@ RSpec.describe Gitlab::Ci::Jwt do
subject(:payload) { described_class.new(build, ttl: 30).payload } subject(:payload) { described_class.new(build, ttl: 30).payload }
it 'has correct values for the standard JWT attributes' do it 'has correct values for the standard JWT attributes' do
Timecop.freeze do freeze_time do
now = Time.now.to_i now = Time.now.to_i
aggregate_failures do aggregate_failures do
......
...@@ -85,7 +85,7 @@ RSpec.describe Gitlab::ConanToken do ...@@ -85,7 +85,7 @@ RSpec.describe Gitlab::ConanToken do
it 'returns the encoded JWT' do it 'returns the encoded JWT' do
allow(SecureRandom).to receive(:uuid).and_return('u-u-i-d') allow(SecureRandom).to receive(:uuid).and_return('u-u-i-d')
Timecop.freeze do freeze_time do
jwt = build_jwt(access_token_id: 123, user_id: 456) jwt = build_jwt(access_token_id: 123, user_id: 456)
token = described_class.new(access_token_id: 123, user_id: 456) token = described_class.new(access_token_id: 123, user_id: 456)
......
...@@ -34,7 +34,7 @@ RSpec.describe Gitlab::CycleAnalytics::CodeStage do ...@@ -34,7 +34,7 @@ RSpec.describe Gitlab::CycleAnalytics::CodeStage do
describe '#project_median' do describe '#project_median' do
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
it 'counts median from issues with metrics' do it 'counts median from issues with metrics' do
...@@ -76,7 +76,7 @@ RSpec.describe Gitlab::CycleAnalytics::CodeStage do ...@@ -76,7 +76,7 @@ RSpec.describe Gitlab::CycleAnalytics::CodeStage do
describe '#group_median' do describe '#group_median' do
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
it 'counts median from issues with metrics' do it 'counts median from issues with metrics' do
......
...@@ -29,7 +29,7 @@ RSpec.describe Gitlab::CycleAnalytics::IssueStage do ...@@ -29,7 +29,7 @@ RSpec.describe Gitlab::CycleAnalytics::IssueStage do
describe '#median' do describe '#median' do
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
it 'counts median from issues with metrics' do it 'counts median from issues with metrics' do
...@@ -65,7 +65,7 @@ RSpec.describe Gitlab::CycleAnalytics::IssueStage do ...@@ -65,7 +65,7 @@ RSpec.describe Gitlab::CycleAnalytics::IssueStage do
describe '#group_median' do describe '#group_median' do
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
it 'counts median from issues with metrics' do it 'counts median from issues with metrics' do
...@@ -87,7 +87,7 @@ RSpec.describe Gitlab::CycleAnalytics::IssueStage do ...@@ -87,7 +87,7 @@ RSpec.describe Gitlab::CycleAnalytics::IssueStage do
describe '#group_median' do describe '#group_median' do
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
it 'counts median from issues with metrics' do it 'counts median from issues with metrics' do
......
...@@ -29,7 +29,7 @@ RSpec.describe Gitlab::CycleAnalytics::PlanStage do ...@@ -29,7 +29,7 @@ RSpec.describe Gitlab::CycleAnalytics::PlanStage do
describe '#project_median' do describe '#project_median' do
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
it 'counts median from issues with metrics' do it 'counts median from issues with metrics' do
...@@ -67,7 +67,7 @@ RSpec.describe Gitlab::CycleAnalytics::PlanStage do ...@@ -67,7 +67,7 @@ RSpec.describe Gitlab::CycleAnalytics::PlanStage do
describe '#group_median' do describe '#group_median' do
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
it 'counts median from issues with metrics' do it 'counts median from issues with metrics' do
......
...@@ -27,7 +27,7 @@ RSpec.describe Gitlab::CycleAnalytics::ReviewStage do ...@@ -27,7 +27,7 @@ RSpec.describe Gitlab::CycleAnalytics::ReviewStage do
describe '#project_median' do describe '#project_median' do
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
it 'counts median from issues with metrics' do it 'counts median from issues with metrics' do
...@@ -70,7 +70,7 @@ RSpec.describe Gitlab::CycleAnalytics::ReviewStage do ...@@ -70,7 +70,7 @@ RSpec.describe Gitlab::CycleAnalytics::ReviewStage do
describe '#group_median' do describe '#group_median' do
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
it 'counts median from issues with metrics' do it 'counts median from issues with metrics' do
......
...@@ -231,7 +231,7 @@ RSpec.describe Gitlab::CycleAnalytics::StageSummary do ...@@ -231,7 +231,7 @@ RSpec.describe Gitlab::CycleAnalytics::StageSummary do
context 'when `from` and `to` are within a day' do context 'when `from` and `to` are within a day' do
it 'returns the number of deployments made on that day' do it 'returns the number of deployments made on that day' do
Timecop.freeze(Time.now) do freeze_time do
create(:deployment, :success, project: project) create(:deployment, :success, project: project)
options[:from] = options[:to] = Time.now options[:from] = options[:to] = Time.now
......
...@@ -32,7 +32,7 @@ RSpec.describe Gitlab::CycleAnalytics::StagingStage do ...@@ -32,7 +32,7 @@ RSpec.describe Gitlab::CycleAnalytics::StagingStage do
describe '#project_median' do describe '#project_median' do
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
it 'counts median from issues with metrics' do it 'counts median from issues with metrics' do
...@@ -79,7 +79,7 @@ RSpec.describe Gitlab::CycleAnalytics::StagingStage do ...@@ -79,7 +79,7 @@ RSpec.describe Gitlab::CycleAnalytics::StagingStage do
describe '#group_median' do describe '#group_median' do
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
it 'counts median from issues with metrics' do it 'counts median from issues with metrics' do
......
...@@ -37,7 +37,7 @@ RSpec.describe Gitlab::CycleAnalytics::TestStage do ...@@ -37,7 +37,7 @@ RSpec.describe Gitlab::CycleAnalytics::TestStage do
end end
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
it 'counts median from issues with metrics' do it 'counts median from issues with metrics' do
......
...@@ -86,7 +86,7 @@ RSpec.describe Gitlab::Database::Migrations::BackgroundMigrationHelpers do ...@@ -86,7 +86,7 @@ RSpec.describe Gitlab::Database::Migrations::BackgroundMigrationHelpers do
let!(:id3) { create(:user).id } let!(:id3) { create(:user).id }
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
before do before do
......
...@@ -7,7 +7,7 @@ RSpec.describe Gitlab::ExternalAuthorization::Access, :clean_gitlab_redis_cache ...@@ -7,7 +7,7 @@ RSpec.describe Gitlab::ExternalAuthorization::Access, :clean_gitlab_redis_cache
describe '#loaded?' do describe '#loaded?' do
it 'is `true` when it was loaded recently' do it 'is `true` when it was loaded recently' do
Timecop.freeze do freeze_time do
allow(access).to receive(:loaded_at).and_return(5.minutes.ago) allow(access).to receive(:loaded_at).and_return(5.minutes.ago)
expect(access).to be_loaded expect(access).to be_loaded
...@@ -19,7 +19,7 @@ RSpec.describe Gitlab::ExternalAuthorization::Access, :clean_gitlab_redis_cache ...@@ -19,7 +19,7 @@ RSpec.describe Gitlab::ExternalAuthorization::Access, :clean_gitlab_redis_cache
end end
it 'is `false` when there the result was loaded a long time ago' do it 'is `false` when there the result was loaded a long time ago' do
Timecop.freeze do freeze_time do
allow(access).to receive(:loaded_at).and_return(2.weeks.ago) allow(access).to receive(:loaded_at).and_return(2.weeks.ago)
expect(access).not_to be_loaded expect(access).not_to be_loaded
...@@ -70,7 +70,7 @@ RSpec.describe Gitlab::ExternalAuthorization::Access, :clean_gitlab_redis_cache ...@@ -70,7 +70,7 @@ RSpec.describe Gitlab::ExternalAuthorization::Access, :clean_gitlab_redis_cache
end end
it 'stores the result in redis' do it 'stores the result in redis' do
Timecop.freeze do freeze_time do
fake_cache = double fake_cache = double
expect(fake_cache).to receive(:store).with(true, nil, Time.now) expect(fake_cache).to receive(:store).with(true, nil, Time.now)
expect(access).to receive(:cache).and_return(fake_cache) expect(access).to receive(:cache).and_return(fake_cache)
...@@ -118,7 +118,7 @@ RSpec.describe Gitlab::ExternalAuthorization::Access, :clean_gitlab_redis_cache ...@@ -118,7 +118,7 @@ RSpec.describe Gitlab::ExternalAuthorization::Access, :clean_gitlab_redis_cache
end end
it 'does not load from the webservice' do it 'does not load from the webservice' do
Timecop.freeze do freeze_time do
expect(fake_cache).to receive(:load).and_return([true, nil, Time.now]) expect(fake_cache).to receive(:load).and_return([true, nil, Time.now])
expect(access).to receive(:load_from_cache).and_call_original expect(access).to receive(:load_from_cache).and_call_original
...@@ -129,7 +129,7 @@ RSpec.describe Gitlab::ExternalAuthorization::Access, :clean_gitlab_redis_cache ...@@ -129,7 +129,7 @@ RSpec.describe Gitlab::ExternalAuthorization::Access, :clean_gitlab_redis_cache
end end
it 'loads from the webservice when the cached result was too old' do it 'loads from the webservice when the cached result was too old' do
Timecop.freeze do freeze_time do
expect(fake_cache).to receive(:load).and_return([true, nil, 2.days.ago]) expect(fake_cache).to receive(:load).and_return([true, nil, 2.days.ago])
expect(access).to receive(:load_from_cache).and_call_original expect(access).to receive(:load_from_cache).and_call_original
......
...@@ -22,7 +22,7 @@ RSpec.describe Gitlab::ExternalAuthorization::Cache, :clean_gitlab_redis_cache d ...@@ -22,7 +22,7 @@ RSpec.describe Gitlab::ExternalAuthorization::Cache, :clean_gitlab_redis_cache d
describe '#load' do describe '#load' do
it 'reads stored info from redis' do it 'reads stored info from redis' do
Timecop.freeze do freeze_time do
set_in_redis(:access, false) set_in_redis(:access, false)
set_in_redis(:reason, 'Access denied for now') set_in_redis(:reason, 'Access denied for now')
set_in_redis(:refreshed_at, Time.now) set_in_redis(:refreshed_at, Time.now)
...@@ -38,7 +38,7 @@ RSpec.describe Gitlab::ExternalAuthorization::Cache, :clean_gitlab_redis_cache d ...@@ -38,7 +38,7 @@ RSpec.describe Gitlab::ExternalAuthorization::Cache, :clean_gitlab_redis_cache d
describe '#store' do describe '#store' do
it 'sets the values in redis' do it 'sets the values in redis' do
Timecop.freeze do freeze_time do
cache.store(true, 'the reason', Time.now) cache.store(true, 'the reason', Time.now)
expect(read_from_redis(:access)).to eq('true') expect(read_from_redis(:access)).to eq('true')
......
...@@ -38,7 +38,7 @@ RSpec.describe Gitlab::GithubImport::Importer::LabelLinksImporter do ...@@ -38,7 +38,7 @@ RSpec.describe Gitlab::GithubImport::Importer::LabelLinksImporter do
.to receive(:find_target_id) .to receive(:find_target_id)
.and_return(1) .and_return(1)
Timecop.freeze do freeze_time do
expect(Gitlab::Database) expect(Gitlab::Database)
.to receive(:bulk_insert) .to receive(:bulk_insert)
.with( .with(
......
...@@ -85,13 +85,13 @@ RSpec.describe Gitlab::GithubImport::Importer::LabelsImporter, :clean_gitlab_red ...@@ -85,13 +85,13 @@ RSpec.describe Gitlab::GithubImport::Importer::LabelsImporter, :clean_gitlab_red
end end
it 'includes the created timestamp' do it 'includes the created timestamp' do
Timecop.freeze do freeze_time do
expect(label_hash[:created_at]).to eq(Time.zone.now) expect(label_hash[:created_at]).to eq(Time.zone.now)
end end
end end
it 'includes the updated timestamp' do it 'includes the updated timestamp' do
Timecop.freeze do freeze_time do
expect(label_hash[:updated_at]).to eq(Time.zone.now) expect(label_hash[:updated_at]).to eq(Time.zone.now)
end end
end end
......
...@@ -164,7 +164,7 @@ RSpec.describe Gitlab::GithubImport::Importer::PullRequestsImporter do ...@@ -164,7 +164,7 @@ RSpec.describe Gitlab::GithubImport::Importer::PullRequestsImporter do
.to receive(:increment) .to receive(:increment)
.and_call_original .and_call_original
Timecop.freeze do freeze_time do
importer.update_repository importer.update_repository
expect(project.last_repository_updated_at).to be_like_time(Time.zone.now) expect(project.last_repository_updated_at).to be_like_time(Time.zone.now)
......
...@@ -261,7 +261,7 @@ RSpec.describe Gitlab::GithubImport::Importer::RepositoryImporter do ...@@ -261,7 +261,7 @@ RSpec.describe Gitlab::GithubImport::Importer::RepositoryImporter do
describe '#update_clone_time' do describe '#update_clone_time' do
it 'sets the timestamp for when the cloning process finished' do it 'sets the timestamp for when the cloning process finished' do
Timecop.freeze do freeze_time do
expect(project) expect(project)
.to receive(:update_column) .to receive(:update_column)
.with(:last_repository_updated_at, Time.zone.now) .with(:last_repository_updated_at, Time.zone.now)
......
# frozen_string_literal: true # frozen_string_literal: true
require 'fast_spec_helper' require 'fast_spec_helper'
require 'timecop'
RSpec.describe Gitlab::IncidentManagement::PagerDuty::IncidentIssueDescription do RSpec.describe Gitlab::IncidentManagement::PagerDuty::IncidentIssueDescription do
describe '#to_s' do describe '#to_s' do
...@@ -50,7 +49,7 @@ RSpec.describe Gitlab::IncidentManagement::PagerDuty::IncidentIssueDescription d ...@@ -50,7 +49,7 @@ RSpec.describe Gitlab::IncidentManagement::PagerDuty::IncidentIssueDescription d
let(:created_at) { nil } let(:created_at) { nil }
it 'description contains current time in UTC' do it 'description contains current time in UTC' do
Timecop.freeze do freeze_time do
now = Time.current.utc.strftime('%d %B %Y, %-l:%M%p (%Z)') now = Time.current.utc.strftime('%d %B %Y, %-l:%M%p (%Z)')
expect(to_s).to include( expect(to_s).to include(
......
...@@ -8,7 +8,7 @@ RSpec.describe Gitlab::LogTimestampFormatter do ...@@ -8,7 +8,7 @@ RSpec.describe Gitlab::LogTimestampFormatter do
let(:formatted_timestamp) { Time.now.utc.iso8601(3) } let(:formatted_timestamp) { Time.now.utc.iso8601(3) }
it 'logs the timestamp in UTC and ISO8601.3 format' do it 'logs the timestamp in UTC and ISO8601.3 format' do
Timecop.freeze(Time.now) do freeze_time do
expect(subject.call('', Time.now, '', '')).to include formatted_timestamp expect(subject.call('', Time.now, '', '')).to include formatted_timestamp
end end
end end
......
...@@ -30,7 +30,7 @@ RSpec.describe Gitlab::Metrics::MethodCall do ...@@ -30,7 +30,7 @@ RSpec.describe Gitlab::Metrics::MethodCall do
end end
around do |example| around do |example|
Timecop.freeze do freeze_time do
example.run example.run
end end
end end
......
...@@ -12,7 +12,7 @@ RSpec.describe Gitlab::Metrics::Samplers::RubySampler do ...@@ -12,7 +12,7 @@ RSpec.describe Gitlab::Metrics::Samplers::RubySampler do
describe '#initialize' do describe '#initialize' do
it 'sets process_start_time_seconds' do it 'sets process_start_time_seconds' do
Timecop.freeze do freeze_time do
expect(sampler.metrics[:process_start_time_seconds].get).to eq(Time.now.to_i) expect(sampler.metrics[:process_start_time_seconds].get).to eq(Time.now.to_i)
end end
end end
......
...@@ -50,7 +50,7 @@ RSpec.describe Gitlab::PhabricatorImport::Cache::Map, :clean_gitlab_redis_cache ...@@ -50,7 +50,7 @@ RSpec.describe Gitlab::PhabricatorImport::Cache::Map, :clean_gitlab_redis_cache
describe '#set_gitlab_model' do describe '#set_gitlab_model' do
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
it 'sets the class and id in redis with a ttl' do it 'sets the class and id in redis with a ttl' do
......
...@@ -4,7 +4,7 @@ require 'spec_helper' ...@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe Gitlab::Prometheus::Queries::AdditionalMetricsEnvironmentQuery do RSpec.describe Gitlab::Prometheus::Queries::AdditionalMetricsEnvironmentQuery do
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
include_examples 'additional metrics query' do include_examples 'additional metrics query' do
......
...@@ -28,7 +28,7 @@ RSpec.describe Gitlab::Prometheus::Queries::ValidateQuery do ...@@ -28,7 +28,7 @@ RSpec.describe Gitlab::Prometheus::Queries::ValidateQuery do
let(:error_message) { "invalid parameter 'query': 1:9: parse error: unexpected identifier \"query\"" } let(:error_message) { "invalid parameter 'query': 1:9: parse error: unexpected identifier \"query\"" }
it 'returns invalid' do it 'returns invalid' do
Timecop.freeze do freeze_time do
stub_prometheus_query_error( stub_prometheus_query_error(
prometheus_query_with_time_url(query, Time.now), prometheus_query_with_time_url(query, Time.now),
error_message error_message
...@@ -53,7 +53,7 @@ RSpec.describe Gitlab::Prometheus::Queries::ValidateQuery do ...@@ -53,7 +53,7 @@ RSpec.describe Gitlab::Prometheus::Queries::ValidateQuery do
end end
it 'catches exception and returns invalid' do it 'catches exception and returns invalid' do
Timecop.freeze do freeze_time do
expect(subject.query(query)).to eq(valid: false, error: message) expect(subject.query(query)).to eq(valid: false, error: message)
end end
end end
......
...@@ -136,7 +136,7 @@ RSpec.describe Gitlab::PrometheusClient do ...@@ -136,7 +136,7 @@ RSpec.describe Gitlab::PrometheusClient do
let(:query_url) { prometheus_query_with_time_url(prometheus_query, Time.now.utc) } let(:query_url) { prometheus_query_with_time_url(prometheus_query, Time.now.utc) }
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
context 'when request returns vector results' do context 'when request returns vector results' do
...@@ -195,7 +195,7 @@ RSpec.describe Gitlab::PrometheusClient do ...@@ -195,7 +195,7 @@ RSpec.describe Gitlab::PrometheusClient do
let(:query_url) { prometheus_query_with_time_url(query, Time.now.utc) } let(:query_url) { prometheus_query_with_time_url(query, Time.now.utc) }
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
context 'when request returns vector results' do context 'when request returns vector results' do
...@@ -228,7 +228,7 @@ RSpec.describe Gitlab::PrometheusClient do ...@@ -228,7 +228,7 @@ RSpec.describe Gitlab::PrometheusClient do
let(:query_url) { prometheus_series_url('series_name', 'other_service') } let(:query_url) { prometheus_series_url('series_name', 'other_service') }
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
it 'calls endpoint and returns list of series' do it 'calls endpoint and returns list of series' do
...@@ -259,7 +259,7 @@ RSpec.describe Gitlab::PrometheusClient do ...@@ -259,7 +259,7 @@ RSpec.describe Gitlab::PrometheusClient do
let(:query_url) { prometheus_query_range_url(prometheus_query) } let(:query_url) { prometheus_query_range_url(prometheus_query) }
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
context 'when non utc time is passed' do context 'when non utc time is passed' do
...@@ -358,7 +358,7 @@ RSpec.describe Gitlab::PrometheusClient do ...@@ -358,7 +358,7 @@ RSpec.describe Gitlab::PrometheusClient do
let(:query_url) { prometheus_query_url(prometheus_query) } let(:query_url) { prometheus_query_url(prometheus_query) }
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
context 'when response status code is 200' do context 'when response status code is 200' do
......
# frozen_string_literal: true # frozen_string_literal: true
require 'fast_spec_helper' require 'fast_spec_helper'
require 'timecop'
RSpec.describe Gitlab::SidekiqMiddleware::DuplicateJobs::Strategies::UntilExecuting do RSpec.describe Gitlab::SidekiqMiddleware::DuplicateJobs::Strategies::UntilExecuting do
let(:fake_duplicate_job) do let(:fake_duplicate_job) do
...@@ -77,7 +76,7 @@ RSpec.describe Gitlab::SidekiqMiddleware::DuplicateJobs::Strategies::UntilExecut ...@@ -77,7 +76,7 @@ RSpec.describe Gitlab::SidekiqMiddleware::DuplicateJobs::Strategies::UntilExecut
context 'scheduled in the future' do context 'scheduled in the future' do
it 'adds the jid of the existing job to the job hash' do it 'adds the jid of the existing job to the job hash' do
Timecop.freeze do freeze_time do
allow(fake_duplicate_job).to receive(:scheduled?).twice.and_return(true) allow(fake_duplicate_job).to receive(:scheduled?).twice.and_return(true)
allow(fake_duplicate_job).to receive(:scheduled_at).and_return(Time.now + time_diff) allow(fake_duplicate_job).to receive(:scheduled_at).and_return(Time.now + time_diff)
allow(fake_duplicate_job).to receive(:options).and_return({ including_scheduled: true }) allow(fake_duplicate_job).to receive(:options).and_return({ including_scheduled: true })
......
...@@ -15,7 +15,7 @@ RSpec.describe Gitlab::UpdatedNotesPaginator do ...@@ -15,7 +15,7 @@ RSpec.describe Gitlab::UpdatedNotesPaginator do
let(:page_1_boundary) { page_1.last.updated_at + NotesFinder::FETCH_OVERLAP } let(:page_1_boundary) { page_1.last.updated_at + NotesFinder::FETCH_OVERLAP }
around do |example| around do |example|
Timecop.freeze do freeze_time do
example.run example.run
end end
end end
......
...@@ -52,7 +52,7 @@ RSpec.describe MigrateIssueTrackersData do ...@@ -52,7 +52,7 @@ RSpec.describe MigrateIssueTrackersData do
it 'schedules background migrations at correct time' do it 'schedules background migrations at correct time' do
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
Timecop.freeze do freeze_time do
migrate! migrate!
expect(migration_name).to be_scheduled_delayed_migration(3.minutes, jira_service.id, bugzilla_service.id) expect(migration_name).to be_scheduled_delayed_migration(3.minutes, jira_service.id, bugzilla_service.id)
......
...@@ -19,7 +19,7 @@ RSpec.describe BackfillProjectSettings, :sidekiq, schema: 20200114113341 do ...@@ -19,7 +19,7 @@ RSpec.describe BackfillProjectSettings, :sidekiq, schema: 20200114113341 do
it 'schedules BackfillProjectSettings background jobs' do it 'schedules BackfillProjectSettings background jobs' do
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
Timecop.freeze do freeze_time do
migrate! migrate!
expect(described_class::MIGRATION).to be_scheduled_delayed_migration(2.minutes, 1, 2) expect(described_class::MIGRATION).to be_scheduled_delayed_migration(2.minutes, 1, 2)
......
...@@ -53,7 +53,7 @@ RSpec.describe RescheduleMigrateIssueTrackersData do ...@@ -53,7 +53,7 @@ RSpec.describe RescheduleMigrateIssueTrackersData do
describe "#up" do describe "#up" do
it 'schedules background migrations at correct time' do it 'schedules background migrations at correct time' do
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
Timecop.freeze do freeze_time do
migrate! migrate!
expect(migration_name).to be_scheduled_delayed_migration(3.minutes, jira_service.id, bugzilla_service.id) expect(migration_name).to be_scheduled_delayed_migration(3.minutes, jira_service.id, bugzilla_service.id)
......
...@@ -27,7 +27,7 @@ RSpec.describe BackfillDeploymentClustersFromDeployments, :migration, :sidekiq, ...@@ -27,7 +27,7 @@ RSpec.describe BackfillDeploymentClustersFromDeployments, :migration, :sidekiq,
batch_2_end = create_deployment(**deployment_data) batch_2_end = create_deployment(**deployment_data)
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
Timecop.freeze do freeze_time do
migrate! migrate!
# batch 1 # batch 1
......
...@@ -17,7 +17,7 @@ RSpec.describe BackfillNamespaceSettings, :sidekiq, schema: 20200703124823 do ...@@ -17,7 +17,7 @@ RSpec.describe BackfillNamespaceSettings, :sidekiq, schema: 20200703124823 do
it 'schedules BackfillNamespaceSettings background jobs' do it 'schedules BackfillNamespaceSettings background jobs' do
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
Timecop.freeze do freeze_time do
migrate! migrate!
expect(described_class::MIGRATION).to be_scheduled_delayed_migration(2.minutes, 1, 2) expect(described_class::MIGRATION).to be_scheduled_delayed_migration(2.minutes, 1, 2)
......
...@@ -30,7 +30,7 @@ RSpec.describe BackfillImportedSnippetRepositories do ...@@ -30,7 +30,7 @@ RSpec.describe BackfillImportedSnippetRepositories do
create_snippet(10) create_snippet(10)
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
Timecop.freeze do freeze_time do
migrate! migrate!
expect(described_class::MIGRATION) expect(described_class::MIGRATION)
......
...@@ -28,7 +28,7 @@ RSpec.describe BackfillSnippetRepositories do ...@@ -28,7 +28,7 @@ RSpec.describe BackfillSnippetRepositories do
stub_const("#{described_class.name}::BATCH_SIZE", 2) stub_const("#{described_class.name}::BATCH_SIZE", 2)
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
Timecop.freeze do freeze_time do
migrate! migrate!
expect(described_class::MIGRATION) expect(described_class::MIGRATION)
......
...@@ -33,7 +33,7 @@ RSpec.describe EnqueueResetMergeStatusSecondRun do ...@@ -33,7 +33,7 @@ RSpec.describe EnqueueResetMergeStatusSecondRun do
stub_const("#{described_class.name}::BATCH_SIZE", 2) stub_const("#{described_class.name}::BATCH_SIZE", 2)
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
Timecop.freeze do freeze_time do
migrate! migrate!
expect(described_class::MIGRATION) expect(described_class::MIGRATION)
......
...@@ -33,7 +33,7 @@ RSpec.describe EnqueueResetMergeStatus do ...@@ -33,7 +33,7 @@ RSpec.describe EnqueueResetMergeStatus do
stub_const("#{described_class.name}::BATCH_SIZE", 2) stub_const("#{described_class.name}::BATCH_SIZE", 2)
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
Timecop.freeze do freeze_time do
migrate! migrate!
expect(described_class::MIGRATION) expect(described_class::MIGRATION)
......
...@@ -20,7 +20,7 @@ RSpec.describe FixProjectsWithoutProjectFeature do ...@@ -20,7 +20,7 @@ RSpec.describe FixProjectsWithoutProjectFeature do
around do |example| around do |example|
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
Timecop.freeze do freeze_time do
example.call example.call
end end
end end
......
...@@ -20,7 +20,7 @@ RSpec.describe FixProjectsWithoutPrometheusService, :migration do ...@@ -20,7 +20,7 @@ RSpec.describe FixProjectsWithoutPrometheusService, :migration do
around do |example| around do |example|
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
Timecop.freeze do freeze_time do
example.call example.call
end end
end end
......
...@@ -29,7 +29,7 @@ RSpec.describe FixWrongPagesAccessLevel, :sidekiq_might_not_need_inline, schema: ...@@ -29,7 +29,7 @@ RSpec.describe FixWrongPagesAccessLevel, :sidekiq_might_not_need_inline, schema:
it 'correctly schedules background migrations' do it 'correctly schedules background migrations' do
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
Timecop.freeze do freeze_time do
first_id = create_project_feature("project1", project_class::PRIVATE, feature_class::PRIVATE).id first_id = create_project_feature("project1", project_class::PRIVATE, feature_class::PRIVATE).id
last_id = create_project_feature("project2", project_class::PRIVATE, feature_class::PUBLIC).id last_id = create_project_feature("project2", project_class::PRIVATE, feature_class::PUBLIC).id
......
...@@ -53,7 +53,7 @@ RSpec.describe MigrateDiscussionIdOnPromotedEpics do ...@@ -53,7 +53,7 @@ RSpec.describe MigrateDiscussionIdOnPromotedEpics do
stub_const("#{described_class.name}::BATCH_SIZE", 2) stub_const("#{described_class.name}::BATCH_SIZE", 2)
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
Timecop.freeze do freeze_time do
migrate! migrate!
expect(migration_name).to be_scheduled_delayed_migration(2.minutes, %w(id1 id2)) expect(migration_name).to be_scheduled_delayed_migration(2.minutes, %w(id1 id2))
...@@ -69,7 +69,7 @@ RSpec.describe MigrateDiscussionIdOnPromotedEpics do ...@@ -69,7 +69,7 @@ RSpec.describe MigrateDiscussionIdOnPromotedEpics do
create_note(create_epic, 'id3') create_note(create_epic, 'id3')
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
Timecop.freeze do freeze_time do
migrate! migrate!
expect(migration_name).to be_scheduled_delayed_migration(2.minutes, %w(id1)) expect(migration_name).to be_scheduled_delayed_migration(2.minutes, %w(id1))
......
...@@ -21,7 +21,7 @@ RSpec.describe ScheduleCalculateWikiSizes do ...@@ -21,7 +21,7 @@ RSpec.describe ScheduleCalculateWikiSizes do
let!(:project_statistic3) { project_statistics.create!(project_id: project3.id, namespace_id: namespace.id, wiki_size: nil) } let!(:project_statistic3) { project_statistics.create!(project_id: project3.id, namespace_id: namespace.id, wiki_size: nil) }
it 'schedules a background migration' do it 'schedules a background migration' do
Timecop.freeze do freeze_time do
migrate! migrate!
expect(migration_name).to be_scheduled_delayed_migration(5.minutes, project_statistic2.id, project_statistic3.id) expect(migration_name).to be_scheduled_delayed_migration(5.minutes, project_statistic2.id, project_statistic3.id)
...@@ -49,7 +49,7 @@ RSpec.describe ScheduleCalculateWikiSizes do ...@@ -49,7 +49,7 @@ RSpec.describe ScheduleCalculateWikiSizes do
it 'does not schedule a background migration' do it 'does not schedule a background migration' do
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
Timecop.freeze do freeze_time do
migrate! migrate!
expect(BackgroundMigrationWorker.jobs.size).to eq 0 expect(BackgroundMigrationWorker.jobs.size).to eq 0
......
...@@ -22,7 +22,7 @@ RSpec.describe ScheduleFillValidTimeForPagesDomainCertificates do ...@@ -22,7 +22,7 @@ RSpec.describe ScheduleFillValidTimeForPagesDomainCertificates do
it 'correctly schedules background migrations' do it 'correctly schedules background migrations' do
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
Timecop.freeze do freeze_time do
migrate! migrate!
first_id = domains_table.find_by_domain("domain3.example.com").id first_id = domains_table.find_by_domain("domain3.example.com").id
......
...@@ -40,7 +40,7 @@ RSpec.describe ScheduleMigrateSecurityScans, :sidekiq do ...@@ -40,7 +40,7 @@ RSpec.describe ScheduleMigrateSecurityScans, :sidekiq do
it 'schedules migration of security scans' do it 'schedules migration of security scans' do
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
Timecop.freeze do freeze_time do
migration.up migration.up
expect(described_class::MIGRATION).to be_scheduled_delayed_migration(5.minutes, job_artifact_1.id, job_artifact_1.id) expect(described_class::MIGRATION).to be_scheduled_delayed_migration(5.minutes, job_artifact_1.id, job_artifact_1.id)
...@@ -57,7 +57,7 @@ RSpec.describe ScheduleMigrateSecurityScans, :sidekiq do ...@@ -57,7 +57,7 @@ RSpec.describe ScheduleMigrateSecurityScans, :sidekiq do
it 'schedules migration of security scans' do it 'schedules migration of security scans' do
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
Timecop.freeze do freeze_time do
migration.up migration.up
expect(BackgroundMigrationWorker.jobs).to be_empty expect(BackgroundMigrationWorker.jobs).to be_empty
......
...@@ -17,7 +17,7 @@ RSpec.describe SchedulePagesMetadataMigration do ...@@ -17,7 +17,7 @@ RSpec.describe SchedulePagesMetadataMigration do
it 'schedules pages metadata migration' do it 'schedules pages metadata migration' do
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
Timecop.freeze do freeze_time do
migrate! migrate!
expect(described_class::MIGRATION).to be_scheduled_delayed_migration(2.minutes, 111, 111) expect(described_class::MIGRATION).to be_scheduled_delayed_migration(2.minutes, 111, 111)
......
...@@ -31,7 +31,7 @@ RSpec.describe SchedulePopulateMergeRequestAssigneesTable do ...@@ -31,7 +31,7 @@ RSpec.describe SchedulePopulateMergeRequestAssigneesTable do
stub_const("#{described_class.name}::BATCH_SIZE", 2) stub_const("#{described_class.name}::BATCH_SIZE", 2)
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
Timecop.freeze do freeze_time do
migrate! migrate!
expect(described_class::MIGRATION) expect(described_class::MIGRATION)
......
...@@ -38,7 +38,7 @@ RSpec.describe SchedulePopulatePersonalSnippetStatistics do ...@@ -38,7 +38,7 @@ RSpec.describe SchedulePopulatePersonalSnippetStatistics do
stub_const("#{described_class}::BATCH_SIZE", 4) stub_const("#{described_class}::BATCH_SIZE", 4)
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
Timecop.freeze do freeze_time do
migrate! migrate!
aggregate_failures do aggregate_failures do
......
...@@ -43,7 +43,7 @@ RSpec.describe SchedulePopulateProjectSnippetStatistics do ...@@ -43,7 +43,7 @@ RSpec.describe SchedulePopulateProjectSnippetStatistics do
stub_const("#{described_class}::BATCH_SIZE", 4) stub_const("#{described_class}::BATCH_SIZE", 4)
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
Timecop.freeze do freeze_time do
migrate! migrate!
aggregate_failures do aggregate_failures do
......
...@@ -32,7 +32,7 @@ RSpec.describe SchedulePopulateUserHighestRolesTable do ...@@ -32,7 +32,7 @@ RSpec.describe SchedulePopulateUserHighestRolesTable do
stub_const("#{described_class.name}::BATCH_SIZE", 2) stub_const("#{described_class.name}::BATCH_SIZE", 2)
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
Timecop.freeze do freeze_time do
migrate! migrate!
expect(described_class::MIGRATION).to be_scheduled_delayed_migration(5.minutes, 1, 4) expect(described_class::MIGRATION).to be_scheduled_delayed_migration(5.minutes, 1, 4)
......
...@@ -16,7 +16,7 @@ RSpec.describe ScheduleRecalculateProjectAuthorizationsSecondRun do ...@@ -16,7 +16,7 @@ RSpec.describe ScheduleRecalculateProjectAuthorizationsSecondRun do
it 'schedules background migration' do it 'schedules background migration' do
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
Timecop.freeze do freeze_time do
migrate! migrate!
expect(BackgroundMigrationWorker.jobs.size).to eq(2) expect(BackgroundMigrationWorker.jobs.size).to eq(2)
......
...@@ -26,7 +26,7 @@ RSpec.describe ScheduleRecalculateProjectAuthorizations do ...@@ -26,7 +26,7 @@ RSpec.describe ScheduleRecalculateProjectAuthorizations do
it 'schedules background migration' do it 'schedules background migration' do
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
Timecop.freeze do freeze_time do
migrate! migrate!
expect(BackgroundMigrationWorker.jobs.size).to eq(2) expect(BackgroundMigrationWorker.jobs.size).to eq(2)
...@@ -45,7 +45,7 @@ RSpec.describe ScheduleRecalculateProjectAuthorizations do ...@@ -45,7 +45,7 @@ RSpec.describe ScheduleRecalculateProjectAuthorizations do
access_level: 30) access_level: 30)
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
Timecop.freeze do freeze_time do
migrate! migrate!
expect(BackgroundMigrationWorker.jobs.size).to eq(2) expect(BackgroundMigrationWorker.jobs.size).to eq(2)
......
...@@ -16,7 +16,7 @@ RSpec.describe ScheduleRecalculateProjectAuthorizationsThirdRun do ...@@ -16,7 +16,7 @@ RSpec.describe ScheduleRecalculateProjectAuthorizationsThirdRun do
it 'schedules background migration' do it 'schedules background migration' do
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
Timecop.freeze do freeze_time do
migrate! migrate!
expect(BackgroundMigrationWorker.jobs.size).to eq(2) expect(BackgroundMigrationWorker.jobs.size).to eq(2)
......
...@@ -20,7 +20,7 @@ RSpec.describe ScheduleSyncIssuablesStateId do ...@@ -20,7 +20,7 @@ RSpec.describe ScheduleSyncIssuablesStateId do
it 'correctly schedules issuable sync background migration' do it 'correctly schedules issuable sync background migration' do
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
Timecop.freeze do freeze_time do
migrate! migrate!
expect(migration).to be_scheduled_delayed_migration(120.seconds, resource_1.id, resource_2.id) expect(migration).to be_scheduled_delayed_migration(120.seconds, resource_1.id, resource_2.id)
......
...@@ -20,7 +20,7 @@ RSpec.describe ScheduleSyncIssuablesStateIdWhereNil do ...@@ -20,7 +20,7 @@ RSpec.describe ScheduleSyncIssuablesStateIdWhereNil do
it 'correctly schedules issuable sync background migration' do it 'correctly schedules issuable sync background migration' do
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
Timecop.freeze do freeze_time do
migrate! migrate!
expect(migration).to be_scheduled_delayed_migration(120.seconds, resource_1.id, resource_3.id) expect(migration).to be_scheduled_delayed_migration(120.seconds, resource_1.id, resource_3.id)
......
...@@ -14,7 +14,7 @@ RSpec.describe ScheduleUpdateExistingSubgroupToMatchVisibilityLevelOfParent do ...@@ -14,7 +14,7 @@ RSpec.describe ScheduleUpdateExistingSubgroupToMatchVisibilityLevelOfParent do
create_namespace('child', Gitlab::VisibilityLevel::PUBLIC, parent_id: parent.id) create_namespace('child', Gitlab::VisibilityLevel::PUBLIC, parent_id: parent.id)
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
Timecop.freeze do freeze_time do
migrate! migrate!
expect(BackgroundMigrationWorker.jobs.size).to eq(1) expect(BackgroundMigrationWorker.jobs.size).to eq(1)
...@@ -30,7 +30,7 @@ RSpec.describe ScheduleUpdateExistingSubgroupToMatchVisibilityLevelOfParent do ...@@ -30,7 +30,7 @@ RSpec.describe ScheduleUpdateExistingSubgroupToMatchVisibilityLevelOfParent do
create_namespace('child', Gitlab::VisibilityLevel::PUBLIC, parent_id: middle_group.id) create_namespace('child', Gitlab::VisibilityLevel::PUBLIC, parent_id: middle_group.id)
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
Timecop.freeze do freeze_time do
migrate! migrate!
expect(BackgroundMigrationWorker.jobs.size).to eq(1) expect(BackgroundMigrationWorker.jobs.size).to eq(1)
...@@ -47,7 +47,7 @@ RSpec.describe ScheduleUpdateExistingSubgroupToMatchVisibilityLevelOfParent do ...@@ -47,7 +47,7 @@ RSpec.describe ScheduleUpdateExistingSubgroupToMatchVisibilityLevelOfParent do
create_namespace('child', Gitlab::VisibilityLevel::PUBLIC, parent_id: middle_group.id) create_namespace('child', Gitlab::VisibilityLevel::PUBLIC, parent_id: middle_group.id)
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
Timecop.freeze do freeze_time do
migrate! migrate!
expect(BackgroundMigrationWorker.jobs.size).to eq(1) expect(BackgroundMigrationWorker.jobs.size).to eq(1)
...@@ -66,7 +66,7 @@ RSpec.describe ScheduleUpdateExistingSubgroupToMatchVisibilityLevelOfParent do ...@@ -66,7 +66,7 @@ RSpec.describe ScheduleUpdateExistingSubgroupToMatchVisibilityLevelOfParent do
create_namespace('child', Gitlab::VisibilityLevel::PUBLIC, parent_id: middle_group.id) create_namespace('child', Gitlab::VisibilityLevel::PUBLIC, parent_id: middle_group.id)
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
Timecop.freeze do freeze_time do
migrate! migrate!
expect(BackgroundMigrationWorker.jobs.size).to eq(2) expect(BackgroundMigrationWorker.jobs.size).to eq(2)
......
...@@ -28,7 +28,7 @@ RSpec.describe BoardGroupRecentVisit do ...@@ -28,7 +28,7 @@ RSpec.describe BoardGroupRecentVisit do
let!(:visit) { create :board_group_recent_visit, group: board.group, board: board, user: user, updated_at: 7.days.ago } let!(:visit) { create :board_group_recent_visit, group: board.group, board: board, user: user, updated_at: 7.days.ago }
it 'updates the timestamp' do it 'updates the timestamp' do
Timecop.freeze do freeze_time do
described_class.visited!(user, board) described_class.visited!(user, board)
expect(described_class.count).to eq 1 expect(described_class.count).to eq 1
......
...@@ -28,7 +28,7 @@ RSpec.describe BoardProjectRecentVisit do ...@@ -28,7 +28,7 @@ RSpec.describe BoardProjectRecentVisit do
let!(:visit) { create :board_project_recent_visit, project: board.project, board: board, user: user, updated_at: 7.days.ago } let!(:visit) { create :board_project_recent_visit, project: board.project, board: board, user: user, updated_at: 7.days.ago }
it 'updates the timestamp' do it 'updates the timestamp' do
Timecop.freeze do freeze_time do
described_class.visited!(user, board) described_class.visited!(user, board)
expect(described_class.count).to eq 1 expect(described_class.count).to eq 1
......
...@@ -448,7 +448,7 @@ RSpec.describe Ci::Build do ...@@ -448,7 +448,7 @@ RSpec.describe Ci::Build do
end end
it 'schedules BuildScheduleWorker at the right time' do it 'schedules BuildScheduleWorker at the right time' do
Timecop.freeze do freeze_time do
expect(Ci::BuildScheduleWorker) expect(Ci::BuildScheduleWorker)
.to receive(:perform_at).with(be_like_time(1.minute.since), build.id) .to receive(:perform_at).with(be_like_time(1.minute.since), build.id)
...@@ -496,7 +496,7 @@ RSpec.describe Ci::Build do ...@@ -496,7 +496,7 @@ RSpec.describe Ci::Build do
let(:option) { { start_in: '1 day' } } let(:option) { { start_in: '1 day' } }
it 'returns date after 1 day' do it 'returns date after 1 day' do
Timecop.freeze do freeze_time do
is_expected.to eq(1.day.since) is_expected.to eq(1.day.since)
end end
end end
...@@ -506,7 +506,7 @@ RSpec.describe Ci::Build do ...@@ -506,7 +506,7 @@ RSpec.describe Ci::Build do
let(:option) { { start_in: '1 week' } } let(:option) { { start_in: '1 week' } }
it 'returns date after 1 week' do it 'returns date after 1 week' do
Timecop.freeze do freeze_time do
is_expected.to eq(1.week.since) is_expected.to eq(1.week.since)
end end
end end
...@@ -4087,7 +4087,7 @@ RSpec.describe Ci::Build do ...@@ -4087,7 +4087,7 @@ RSpec.describe Ci::Build do
let(:path) { 'other_artifacts_0.1.2/another-subdirectory/banana_sample.gif' } let(:path) { 'other_artifacts_0.1.2/another-subdirectory/banana_sample.gif' }
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
before do before do
......
...@@ -46,7 +46,7 @@ RSpec.describe Clusters::Applications::Prometheus do ...@@ -46,7 +46,7 @@ RSpec.describe Clusters::Applications::Prometheus do
subject { create(:clusters_applications_prometheus, :installed, cluster: cluster) } subject { create(:clusters_applications_prometheus, :installed, cluster: cluster) }
it 'sets last_update_started_at to now' do it 'sets last_update_started_at to now' do
Timecop.freeze do freeze_time do
expect { subject.make_updating }.to change { subject.reload.last_update_started_at }.to be_within(1.second).of(Time.current) expect { subject.make_updating }.to change { subject.reload.last_update_started_at }.to be_within(1.second).of(Time.current)
end end
end end
...@@ -353,7 +353,7 @@ RSpec.describe Clusters::Applications::Prometheus do ...@@ -353,7 +353,7 @@ RSpec.describe Clusters::Applications::Prometheus do
let(:timestamp) { Time.current - 5.minutes } let(:timestamp) { Time.current - 5.minutes }
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
before do before do
......
...@@ -25,7 +25,7 @@ RSpec.describe PrometheusAdapter, :use_clean_rails_memory_store_caching do ...@@ -25,7 +25,7 @@ RSpec.describe PrometheusAdapter, :use_clean_rails_memory_store_caching do
let(:validation_respone) { { data: { valid: true } } } let(:validation_respone) { { data: { valid: true } } }
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
context 'with valid data' do context 'with valid data' do
...@@ -45,7 +45,7 @@ RSpec.describe PrometheusAdapter, :use_clean_rails_memory_store_caching do ...@@ -45,7 +45,7 @@ RSpec.describe PrometheusAdapter, :use_clean_rails_memory_store_caching do
let(:environment) { build_stubbed(:environment, slug: 'env-slug') } let(:environment) { build_stubbed(:environment, slug: 'env-slug') }
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
context 'with valid data' do context 'with valid data' do
...@@ -85,7 +85,7 @@ RSpec.describe PrometheusAdapter, :use_clean_rails_memory_store_caching do ...@@ -85,7 +85,7 @@ RSpec.describe PrometheusAdapter, :use_clean_rails_memory_store_caching do
let(:deployment_query) { Gitlab::Prometheus::Queries::DeploymentQuery } let(:deployment_query) { Gitlab::Prometheus::Queries::DeploymentQuery }
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
context 'with valid data' do context 'with valid data' do
...@@ -107,7 +107,7 @@ RSpec.describe PrometheusAdapter, :use_clean_rails_memory_store_caching do ...@@ -107,7 +107,7 @@ RSpec.describe PrometheusAdapter, :use_clean_rails_memory_store_caching do
let(:time_window) { [1552642245.067, 1552642095.831] } let(:time_window) { [1552642245.067, 1552642095.831] }
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
context 'with valid data' do context 'with valid data' do
...@@ -137,7 +137,7 @@ RSpec.describe PrometheusAdapter, :use_clean_rails_memory_store_caching do ...@@ -137,7 +137,7 @@ RSpec.describe PrometheusAdapter, :use_clean_rails_memory_store_caching do
end end
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
context 'when service is inactive' do context 'when service is inactive' do
......
...@@ -99,7 +99,7 @@ RSpec.describe Deployment do ...@@ -99,7 +99,7 @@ RSpec.describe Deployment do
end end
it 'starts running' do it 'starts running' do
Timecop.freeze do freeze_time do
expect(deployment).to be_running expect(deployment).to be_running
expect(deployment.finished_at).to be_nil expect(deployment.finished_at).to be_nil
end end
...@@ -110,7 +110,7 @@ RSpec.describe Deployment do ...@@ -110,7 +110,7 @@ RSpec.describe Deployment do
let(:deployment) { create(:deployment, :running) } let(:deployment) { create(:deployment, :running) }
it 'has correct status' do it 'has correct status' do
Timecop.freeze do freeze_time do
deployment.succeed! deployment.succeed!
expect(deployment).to be_success expect(deployment).to be_success
...@@ -137,7 +137,7 @@ RSpec.describe Deployment do ...@@ -137,7 +137,7 @@ RSpec.describe Deployment do
let(:deployment) { create(:deployment, :running) } let(:deployment) { create(:deployment, :running) }
it 'has correct status' do it 'has correct status' do
Timecop.freeze do freeze_time do
deployment.drop! deployment.drop!
expect(deployment).to be_failed expect(deployment).to be_failed
...@@ -157,7 +157,7 @@ RSpec.describe Deployment do ...@@ -157,7 +157,7 @@ RSpec.describe Deployment do
let(:deployment) { create(:deployment, :running) } let(:deployment) { create(:deployment, :running) }
it 'has correct status' do it 'has correct status' do
Timecop.freeze do freeze_time do
deployment.cancel! deployment.cancel!
expect(deployment).to be_canceled expect(deployment).to be_canceled
...@@ -584,7 +584,7 @@ RSpec.describe Deployment do ...@@ -584,7 +584,7 @@ RSpec.describe Deployment do
end end
it 'updates finished_at when transitioning to a finished status' do it 'updates finished_at when transitioning to a finished status' do
Timecop.freeze do freeze_time do
deploy.update_status('success') deploy.update_status('success')
expect(deploy.read_attribute(:finished_at)).to eq(Time.current) expect(deploy.read_attribute(:finished_at)).to eq(Time.current)
......
...@@ -1222,7 +1222,7 @@ RSpec.describe Environment, :use_clean_rails_memory_store_caching do ...@@ -1222,7 +1222,7 @@ RSpec.describe Environment, :use_clean_rails_memory_store_caching do
let(:environment) { build(:environment, :will_auto_stop) } let(:environment) { build(:environment, :will_auto_stop) }
it 'returns when it will expire' do it 'returns when it will expire' do
Timecop.freeze { is_expected.to eq(1.day.to_i) } freeze_time { is_expected.to eq(1.day.to_i) }
end end
end end
...@@ -1248,7 +1248,7 @@ RSpec.describe Environment, :use_clean_rails_memory_store_caching do ...@@ -1248,7 +1248,7 @@ RSpec.describe Environment, :use_clean_rails_memory_store_caching do
end end
with_them do with_them do
it 'sets correct auto_stop_in' do it 'sets correct auto_stop_in' do
Timecop.freeze do freeze_time do
if expected_result.is_a?(Integer) || expected_result.nil? if expected_result.is_a?(Integer) || expected_result.nil?
subject subject
......
...@@ -100,7 +100,7 @@ RSpec.describe Metrics::Dashboard::Annotation do ...@@ -100,7 +100,7 @@ RSpec.describe Metrics::Dashboard::Annotation do
describe '#ending_before' do describe '#ending_before' do
it 'returns annotations only for appointed dashboard' do it 'returns annotations only for appointed dashboard' do
Timecop.freeze do freeze_time do
twelve_minutes_old_annotation = create(:metrics_dashboard_annotation, starting_at: 15.minutes.ago, ending_at: 12.minutes.ago) twelve_minutes_old_annotation = create(:metrics_dashboard_annotation, starting_at: 15.minutes.ago, ending_at: 12.minutes.ago)
create(:metrics_dashboard_annotation, starting_at: 15.minutes.ago, ending_at: 11.minutes.ago) create(:metrics_dashboard_annotation, starting_at: 15.minutes.ago, ending_at: 11.minutes.ago)
......
...@@ -283,7 +283,7 @@ RSpec.describe RemoteMirror, :mailer do ...@@ -283,7 +283,7 @@ RSpec.describe RemoteMirror, :mailer do
let(:remote_mirror) { create(:project, :repository, :remote_mirror).remote_mirrors.first } let(:remote_mirror) { create(:project, :repository, :remote_mirror).remote_mirrors.first }
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
context 'with remote mirroring disabled' do context 'with remote mirroring disabled' do
...@@ -397,7 +397,7 @@ RSpec.describe RemoteMirror, :mailer do ...@@ -397,7 +397,7 @@ RSpec.describe RemoteMirror, :mailer do
let(:timestamp) { Time.current - 5.minutes } let(:timestamp) { Time.current - 5.minutes }
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
before do before do
......
...@@ -228,7 +228,7 @@ RSpec.describe Ci::BuildPresenter do ...@@ -228,7 +228,7 @@ RSpec.describe Ci::BuildPresenter do
let(:build) { create(:ci_build, :scheduled) } let(:build) { create(:ci_build, :scheduled) }
it 'returns execution time' do it 'returns execution time' do
Timecop.freeze do freeze_time do
is_expected.to be_like_time(60.0) is_expected.to be_like_time(60.0)
end end
end end
...@@ -238,7 +238,7 @@ RSpec.describe Ci::BuildPresenter do ...@@ -238,7 +238,7 @@ RSpec.describe Ci::BuildPresenter do
let(:build) { create(:ci_build, :expired_scheduled) } let(:build) { create(:ci_build, :expired_scheduled) }
it 'returns execution time' do it 'returns execution time' do
Timecop.freeze do freeze_time do
is_expected.to eq(0) is_expected.to eq(0)
end end
end end
...@@ -249,7 +249,7 @@ RSpec.describe Ci::BuildPresenter do ...@@ -249,7 +249,7 @@ RSpec.describe Ci::BuildPresenter do
let(:build) { create(:ci_build) } let(:build) { create(:ci_build) }
it 'does not return execution time' do it 'does not return execution time' do
Timecop.freeze do freeze_time do
is_expected.to be_falsy is_expected.to be_falsy
end end
end end
......
...@@ -153,7 +153,7 @@ RSpec.describe API::ConanPackages do ...@@ -153,7 +153,7 @@ RSpec.describe API::ConanPackages do
end end
it 'token has valid validity time' do it 'token has valid validity time' do
Timecop.freeze do freeze_time do
subject subject
payload = JSONWebToken::HMACToken.decode( payload = JSONWebToken::HMACToken.decode(
......
...@@ -415,7 +415,7 @@ RSpec.describe API::Internal::Base do ...@@ -415,7 +415,7 @@ RSpec.describe API::Internal::Base do
let(:env) { {} } let(:env) { {} }
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
before do before do
......
...@@ -16,7 +16,7 @@ RSpec.describe AnalyticsBuildEntity do ...@@ -16,7 +16,7 @@ RSpec.describe AnalyticsBuildEntity do
subject { entity.as_json } subject { entity.as_json }
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
it 'contains the URL' do it 'contains the URL' do
......
...@@ -7,7 +7,7 @@ RSpec.describe Clusters::Applications::ScheduleUpdateService do ...@@ -7,7 +7,7 @@ RSpec.describe Clusters::Applications::ScheduleUpdateService do
let(:project) { create(:project) } let(:project) { create(:project) }
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
context 'when application is able to be updated' do context 'when application is able to be updated' do
......
...@@ -122,7 +122,7 @@ RSpec.describe Deployments::AfterCreateService do ...@@ -122,7 +122,7 @@ RSpec.describe Deployments::AfterCreateService do
end end
it 'renews auto stop at' do it 'renews auto stop at' do
Timecop.freeze do freeze_time do
environment.update!(auto_stop_at: nil) environment.update!(auto_stop_at: nil)
expect { subject.execute } expect { subject.execute }
......
...@@ -19,7 +19,7 @@ RSpec.describe MergeRequests::DeleteNonLatestDiffsService, :clean_gitlab_redis_s ...@@ -19,7 +19,7 @@ RSpec.describe MergeRequests::DeleteNonLatestDiffsService, :clean_gitlab_redis_s
expect(diffs.count).to eq(4) expect(diffs.count).to eq(4)
Timecop.freeze do freeze_time do
expect(DeleteDiffFilesWorker) expect(DeleteDiffFilesWorker)
.to receive(:bulk_perform_in) .to receive(:bulk_perform_in)
.with(5.minutes, [[diffs.first.id], [diffs.second.id]]) .with(5.minutes, [[diffs.first.id], [diffs.second.id]])
......
...@@ -23,7 +23,7 @@ RSpec.describe NoteSummary do ...@@ -23,7 +23,7 @@ RSpec.describe NoteSummary do
describe '#note' do describe '#note' do
it 'returns note hash' do it 'returns note hash' do
Timecop.freeze do freeze_time do
expect(create_note_summary.note).to eq(noteable: noteable, project: project, author: user, note: 'note', expect(create_note_summary.note).to eq(noteable: noteable, project: project, author: user, note: 'note',
created_at: Time.current) created_at: Time.current)
end end
......
...@@ -30,7 +30,7 @@ RSpec.describe Projects::HashedStorage::BaseAttachmentService do ...@@ -30,7 +30,7 @@ RSpec.describe Projects::HashedStorage::BaseAttachmentService do
target_path = Dir.mktmpdir target_path = Dir.mktmpdir
expect(Dir.exist?(target_path)).to be_truthy expect(Dir.exist?(target_path)).to be_truthy
Timecop.freeze do freeze_time do
suffix = Time.current.utc.to_i suffix = Time.current.utc.to_i
subject.send(:discard_path!, target_path) subject.send(:discard_path!, target_path)
......
...@@ -202,7 +202,7 @@ RSpec.describe Releases::CreateService do ...@@ -202,7 +202,7 @@ RSpec.describe Releases::CreateService do
let(:last_release) { project.releases.last } let(:last_release) { project.releases.last }
around do |example| around do |example|
Timecop.freeze { example.run } freeze_time { example.run }
end end
subject { service.execute } subject { service.execute }
......
...@@ -63,7 +63,7 @@ RSpec.shared_examples 'schedules resource mentions migration' do |resource_class ...@@ -63,7 +63,7 @@ RSpec.shared_examples 'schedules resource mentions migration' do |resource_class
it 'schedules background migrations' do it 'schedules background migrations' do
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
Timecop.freeze do freeze_time do
resource_count = is_for_notes ? Note.count : resource_class.count resource_count = is_for_notes ? Note.count : resource_class.count
expect(resource_count).to eq 5 expect(resource_count).to eq 5
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
RSpec.shared_examples 'throttled touch' do RSpec.shared_examples 'throttled touch' do
describe '#touch' do describe '#touch' do
it 'updates the updated_at timestamp' do it 'updates the updated_at timestamp' do
Timecop.freeze do freeze_time do
subject.touch subject.touch
expect(subject.updated_at).to be_like_time(Time.zone.now) expect(subject.updated_at).to be_like_time(Time.zone.now)
end end
......
...@@ -12,7 +12,7 @@ RSpec.describe ClusterUpdateAppWorker do ...@@ -12,7 +12,7 @@ RSpec.describe ClusterUpdateAppWorker do
subject { described_class.new } subject { described_class.new }
around do |example| around do |example|
Timecop.freeze(Time.current) { example.run } freeze_time { example.run }
end end
before do before do
......
...@@ -9,7 +9,7 @@ RSpec.describe RepositoryUpdateRemoteMirrorWorker, :clean_gitlab_redis_shared_st ...@@ -9,7 +9,7 @@ RSpec.describe RepositoryUpdateRemoteMirrorWorker, :clean_gitlab_redis_shared_st
let(:scheduled_time) { Time.current - 5.minutes } let(:scheduled_time) { Time.current - 5.minutes }
around do |example| around do |example|
Timecop.freeze(Time.current) { example.run } freeze_time { example.run }
end end
def expect_mirror_service_to_return(mirror, result, tries = 0) def expect_mirror_service_to_return(mirror, result, tries = 0)
......
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