Commit 18aec09e authored by Alishan Ladhani's avatar Alishan Ladhani

Run autocorrection for RSpec/TimecopFreeze

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