Commit a76b3bd5 authored by Sean Arnold's avatar Sean Arnold

Update Time.now => Time.current

- Services in EE and CE
- Specs included
parent d2971491
...@@ -52,7 +52,7 @@ module Auth ...@@ -52,7 +52,7 @@ module Auth
end end
def self.token_expire_at def self.token_expire_at
Time.now + Gitlab::CurrentSettings.container_registry_token_expire_delay.minutes Time.current + Gitlab::CurrentSettings.container_registry_token_expire_delay.minutes
end end
private private
......
...@@ -201,7 +201,7 @@ module Ci ...@@ -201,7 +201,7 @@ module Ci
labels[:shard] = shard.gsub(METRICS_SHARD_TAG_PREFIX, '') if shard labels[:shard] = shard.gsub(METRICS_SHARD_TAG_PREFIX, '') if shard
end end
job_queue_duration_seconds.observe(labels, Time.now - job.queued_at) unless job.queued_at.nil? job_queue_duration_seconds.observe(labels, Time.current - job.queued_at) unless job.queued_at.nil?
attempt_counter.increment attempt_counter.increment
end end
......
...@@ -33,7 +33,7 @@ module Clusters ...@@ -33,7 +33,7 @@ module Clusters
end end
def timed_out? def timed_out?
Time.now.utc - app.updated_at.utc > ClusterWaitForAppInstallationWorker::TIMEOUT Time.current.utc - app.updated_at.utc > ClusterWaitForAppInstallationWorker::TIMEOUT
end end
def remove_installation_pod def remove_installation_pod
......
...@@ -31,7 +31,7 @@ module Clusters ...@@ -31,7 +31,7 @@ module Clusters
end end
def timed_out? def timed_out?
Time.now.utc - app.updated_at.utc > WaitForUninstallAppWorker::TIMEOUT Time.current.utc - app.updated_at.utc > WaitForUninstallAppWorker::TIMEOUT
end end
def remove_uninstallation_pod def remove_uninstallation_pod
......
...@@ -46,7 +46,7 @@ module Clusters ...@@ -46,7 +46,7 @@ module Clusters
end end
def timed_out? def timed_out?
Time.now.utc - app.updated_at.to_time.utc > ::ClusterWaitForAppUpdateWorker::TIMEOUT Time.current.utc - app.updated_at.to_time.utc > ::ClusterWaitForAppUpdateWorker::TIMEOUT
end end
def remove_pod def remove_pod
......
...@@ -16,9 +16,9 @@ module Clusters ...@@ -16,9 +16,9 @@ module Clusters
return unless application return unless application
if recently_scheduled? if recently_scheduled?
worker_class.perform_in(BACKOFF_DELAY, application.name, application.id, project.id, Time.now) worker_class.perform_in(BACKOFF_DELAY, application.name, application.id, project.id, Time.current)
else else
worker_class.perform_async(application.name, application.id, project.id, Time.now) worker_class.perform_async(application.name, application.id, project.id, Time.current)
end end
end end
...@@ -31,7 +31,7 @@ module Clusters ...@@ -31,7 +31,7 @@ module Clusters
def recently_scheduled? def recently_scheduled?
return false unless application.last_update_started_at return false unless application.last_update_started_at
application.last_update_started_at.utc >= Time.now.utc - BACKOFF_DELAY application.last_update_started_at.utc >= Time.current.utc - BACKOFF_DELAY
end end
end end
end end
......
...@@ -35,7 +35,7 @@ module Clusters ...@@ -35,7 +35,7 @@ module Clusters
end end
def elapsed_time_from_creation(operation) def elapsed_time_from_creation(operation)
Time.now.utc - operation.start_time.to_time.utc Time.current.utc - operation.start_time.to_time.utc
end end
def finalize_creation def finalize_creation
......
...@@ -54,8 +54,8 @@ module Clusters ...@@ -54,8 +54,8 @@ module Clusters
cert = OpenSSL::X509::Certificate.new cert = OpenSSL::X509::Certificate.new
cert.version = 2 cert.version = 2
cert.serial = 0 cert.serial = 0
cert.not_before = Time.now cert.not_before = Time.current
cert.not_after = Time.now + 1000.years cert.not_after = Time.current + 1000.years
cert.public_key = key.public_key cert.public_key = key.public_key
cert.subject = name cert.subject = name
......
...@@ -221,7 +221,7 @@ class IssuableBaseService < BaseService ...@@ -221,7 +221,7 @@ class IssuableBaseService < BaseService
issuable.assign_attributes(params) issuable.assign_attributes(params)
if has_title_or_description_changed?(issuable) if has_title_or_description_changed?(issuable)
issuable.assign_attributes(last_edited_at: Time.now, last_edited_by: current_user) issuable.assign_attributes(last_edited_at: Time.current, last_edited_by: current_user)
end end
before_update(issuable) before_update(issuable)
...@@ -270,7 +270,7 @@ class IssuableBaseService < BaseService ...@@ -270,7 +270,7 @@ class IssuableBaseService < BaseService
if issuable.changed? || params.present? if issuable.changed? || params.present?
issuable.assign_attributes(params.merge(updated_by: current_user, issuable.assign_attributes(params.merge(updated_by: current_user,
last_edited_at: Time.now, last_edited_at: Time.current,
last_edited_by: current_user)) last_edited_by: current_user))
before_update(issuable, skip_spam_check: true) before_update(issuable, skip_spam_check: true)
......
...@@ -8,7 +8,7 @@ module Members ...@@ -8,7 +8,7 @@ module Members
source.members.create( source.members.create(
access_level: Gitlab::Access::DEVELOPER, access_level: Gitlab::Access::DEVELOPER,
user: current_user, user: current_user,
requested_at: Time.now.utc) requested_at: Time.current.utc)
end end
private private
......
...@@ -33,7 +33,7 @@ module Projects ...@@ -33,7 +33,7 @@ module Projects
end end
def order_by_date(tags) def order_by_date(tags)
now = DateTime.now now = DateTime.current
tags.sort_by { |tag| tag.created_at || now }.reverse tags.sort_by { |tag| tag.created_at || now }.reverse
end end
......
...@@ -70,7 +70,7 @@ module Projects ...@@ -70,7 +70,7 @@ module Projects
# #
# @param [String] new_path # @param [String] new_path
def discard_path!(new_path) def discard_path!(new_path)
discarded_path = "#{new_path}-#{Time.now.utc.to_i}" discarded_path = "#{new_path}-#{Time.current.utc.to_i}"
logger.info("Moving existing empty attachments folder from '#{new_path}' to '#{discarded_path}', (PROJECT_ID=#{project.id})") logger.info("Moving existing empty attachments folder from '#{new_path}' to '#{discarded_path}', (PROJECT_ID=#{project.id})")
FileUtils.mv(new_path, discarded_path) FileUtils.mv(new_path, discarded_path)
......
...@@ -121,7 +121,7 @@ module Projects ...@@ -121,7 +121,7 @@ module Projects
end end
def moved_path(path) def moved_path(path)
"#{path}+#{project.id}+moved+#{Time.now.to_i}" "#{path}+#{project.id}+moved+#{Time.current.to_i}"
end end
# The underlying FetchInternalRemote call uses a `git fetch` to move data # The underlying FetchInternalRemote call uses a `git fetch` to move data
......
...@@ -17,7 +17,7 @@ module Spam ...@@ -17,7 +17,7 @@ module Spam
params = { params = {
type: 'comment', type: 'comment',
text: text, text: text,
created_at: DateTime.now, created_at: DateTime.current,
author: owner_name, author: owner_name,
author_email: owner_email, author_email: owner_email,
referrer: options[:referrer] referrer: options[:referrer]
......
...@@ -42,7 +42,7 @@ module Terraform ...@@ -42,7 +42,7 @@ module Terraform
state.lock_xid = params[:lock_id] state.lock_xid = params[:lock_id]
state.locked_by_user = current_user state.locked_by_user = current_user
state.locked_at = Time.now state.locked_at = Time.current
state.save! state.save!
end end
......
...@@ -37,7 +37,7 @@ class VerifyPagesDomainService < BaseService ...@@ -37,7 +37,7 @@ class VerifyPagesDomainService < BaseService
# Prevent any pre-existing grace period from being truncated # Prevent any pre-existing grace period from being truncated
reverify = [domain.enabled_until, VERIFICATION_PERIOD.from_now].compact.max reverify = [domain.enabled_until, VERIFICATION_PERIOD.from_now].compact.max
domain.assign_attributes(verified_at: Time.now, enabled_until: reverify, remove_at: nil) domain.assign_attributes(verified_at: Time.current, enabled_until: reverify, remove_at: nil)
domain.save!(validate: false) domain.save!(validate: false)
if was_disabled if was_disabled
...@@ -73,7 +73,7 @@ class VerifyPagesDomainService < BaseService ...@@ -73,7 +73,7 @@ class VerifyPagesDomainService < BaseService
# A domain is only expired until `disable!` has been called # A domain is only expired until `disable!` has been called
def expired? def expired?
domain.enabled_until && domain.enabled_until < Time.now domain.enabled_until && domain.enabled_until < Time.current
end end
def dns_record_present? def dns_record_present?
......
...@@ -9,7 +9,7 @@ class ClearNamespaceSharedRunnersMinutesService < BaseService ...@@ -9,7 +9,7 @@ class ClearNamespaceSharedRunnersMinutesService < BaseService
def execute def execute
NamespaceStatistics.where(namespace: @namespace).update_all( NamespaceStatistics.where(namespace: @namespace).update_all(
shared_runners_seconds: 0, shared_runners_seconds: 0,
shared_runners_seconds_last_reset: Time.now shared_runners_seconds_last_reset: Time.current
) )
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
......
...@@ -15,8 +15,8 @@ module EE ...@@ -15,8 +15,8 @@ module EE
def attributes def attributes
base_payload.merge(type: SecurityEvent.to_s, base_payload.merge(type: SecurityEvent.to_s,
created_at: DateTime.now, created_at: DateTime.current,
updated_at: DateTime.now, updated_at: DateTime.current,
details: @details.to_yaml) details: @details.to_yaml)
end end
......
...@@ -38,7 +38,7 @@ module EE ...@@ -38,7 +38,7 @@ module EE
if weight_changes_tracking_enabled? if weight_changes_tracking_enabled?
# Only create a resource event here if is_update is true to exclude the move issue operation. # Only create a resource event here if is_update is true to exclude the move issue operation.
# ResourceEvents for moved issues are written within AttributesRewriter. # ResourceEvents for moved issues are written within AttributesRewriter.
EE::ResourceEvents::ChangeWeightService.new([issuable], current_user, Time.now).execute if is_update EE::ResourceEvents::ChangeWeightService.new([issuable], current_user, Time.current).execute if is_update
else else
::SystemNoteService.change_weight_note(issuable, issuable.project, current_user) ::SystemNoteService.change_weight_note(issuable, issuable.project, current_user)
end end
......
...@@ -54,7 +54,7 @@ module Elastic ...@@ -54,7 +54,7 @@ module Elastic
private private
def execute_with_redis(redis) def execute_with_redis(redis)
start_time = Time.now start_time = Time.current
specs = redis.zrangebyscore(REDIS_SET_KEY, '-inf', '+inf', limit: [0, LIMIT], with_scores: true) specs = redis.zrangebyscore(REDIS_SET_KEY, '-inf', '+inf', limit: [0, LIMIT], with_scores: true)
return if specs.empty? return if specs.empty?
...@@ -85,7 +85,7 @@ module Elastic ...@@ -85,7 +85,7 @@ module Elastic
failures_count: failures.count, failures_count: failures.count,
first_score: first_score, first_score: first_score,
last_score: last_score, last_score: last_score,
bulk_execution_duration_s: Time.now - start_time bulk_execution_duration_s: Time.current - start_time
) )
end end
......
...@@ -25,7 +25,7 @@ module Geo ...@@ -25,7 +25,7 @@ module Geo
# @return [Boolean] true if synced, false if not # @return [Boolean] true if synced, false if not
def execute def execute
try_obtain_lease do try_obtain_lease do
start_time = Time.now start_time = Time.current
registry.start! registry.start!
...@@ -60,7 +60,7 @@ module Geo ...@@ -60,7 +60,7 @@ module Geo
download_success: download_result.success, download_success: download_result.success,
bytes_downloaded: download_result.bytes_downloaded, bytes_downloaded: download_result.bytes_downloaded,
primary_missing_file: download_result.primary_missing_file, primary_missing_file: download_result.primary_missing_file,
download_time_s: (Time.now - start_time).to_f.round(3), download_time_s: (Time.current - start_time).to_f.round(3),
reason: download_result.reason reason: download_result.reason
} }
metadata.merge(download_result.extra_details) if download_result.extra_details metadata.merge(download_result.extra_details) if download_result.extra_details
......
...@@ -65,7 +65,7 @@ module Geo ...@@ -65,7 +65,7 @@ module Geo
verification_checksum: checksum, verification_checksum: checksum,
verification_checksum_mismatched: mismatch, verification_checksum_mismatched: mismatch,
checksum_mismatch: mismatch.present?, checksum_mismatch: mismatch.present?,
verified_at: Time.now, verified_at: Time.current,
verification_failure: failure, verification_failure: failure,
verification_retry_count: verification_retry_count, verification_retry_count: verification_retry_count,
retry_at: resync_retry_at, retry_at: resync_retry_at,
......
...@@ -75,7 +75,7 @@ module Geo ...@@ -75,7 +75,7 @@ module Geo
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
def download_time_in_seconds def download_time_in_seconds
(Time.now.to_f - registry.last_synced_at.to_f).round(3) (Time.current.to_f - registry.last_synced_at.to_f).round(3)
end end
def redownload? def redownload?
......
...@@ -15,7 +15,7 @@ module Geo ...@@ -15,7 +15,7 @@ module Geo
def execute def execute
try_obtain_lease do try_obtain_lease do
start_time = Time.now start_time = Time.current
download_result = downloader.execute download_result = downloader.execute
...@@ -49,7 +49,7 @@ module Geo ...@@ -49,7 +49,7 @@ module Geo
bytes_downloaded: download_result.bytes_downloaded, bytes_downloaded: download_result.bytes_downloaded,
failed_before_transfer: download_result.failed_before_transfer, failed_before_transfer: download_result.failed_before_transfer,
primary_missing_file: download_result.primary_missing_file, primary_missing_file: download_result.primary_missing_file,
download_time_s: (Time.now - start_time).to_f.round(3) download_time_s: (Time.current - start_time).to_f.round(3)
} }
log_info("File download", metadata) log_info("File download", metadata)
......
...@@ -33,7 +33,7 @@ module Geo ...@@ -33,7 +33,7 @@ module Geo
repository_state.update!( repository_state.update!(
"#{type}_verification_checksum" => checksum, "#{type}_verification_checksum" => checksum,
"last_#{type}_verification_ran_at" => Time.now, "last_#{type}_verification_ran_at" => Time.current,
"last_#{type}_verification_failure" => failure, "last_#{type}_verification_failure" => failure,
"#{type}_retry_at" => retry_at, "#{type}_retry_at" => retry_at,
"#{type}_retry_count" => retry_count "#{type}_retry_count" => retry_count
......
...@@ -74,7 +74,7 @@ module Geo ...@@ -74,7 +74,7 @@ module Geo
"#{type}_verification_checksum_sha" => checksum, "#{type}_verification_checksum_sha" => checksum,
"#{type}_verification_checksum_mismatched" => mismatch, "#{type}_verification_checksum_mismatched" => mismatch,
"#{type}_checksum_mismatch" => mismatch.present?, "#{type}_checksum_mismatch" => mismatch.present?,
"last_#{type}_verification_ran_at" => Time.now, "last_#{type}_verification_ran_at" => Time.current,
"last_#{type}_verification_failure" => failure, "last_#{type}_verification_failure" => failure,
"#{type}_verification_retry_count" => verification_retry_count, "#{type}_verification_retry_count" => verification_retry_count,
"resync_#{type}" => reverify, "resync_#{type}" => reverify,
......
...@@ -27,7 +27,7 @@ module Groups ...@@ -27,7 +27,7 @@ module Groups
end end
def deletion_schedule_params def deletion_schedule_params
{ marked_for_deletion_on: Time.now.utc, deleting_user: current_user } { marked_for_deletion_on: Time.current.utc, deleting_user: current_user }
end end
def log_audit_event def log_audit_event
......
...@@ -12,7 +12,7 @@ module MergeRequests ...@@ -12,7 +12,7 @@ module MergeRequests
title_slug = Gitlab::Utils.slugify(vulnerability.title) title_slug = Gitlab::Utils.slugify(vulnerability.title)
source_branch = "remediate/%s-%s" % [ source_branch = "remediate/%s-%s" % [
title_slug[0..74], title_slug[0..74],
Time.now.strftime("D%Y%m%dT%H%M%S") Time.current.strftime("D%Y%m%dT%H%M%S")
] ]
target_branch = vulnerability.target_branch || @project.default_branch target_branch = vulnerability.target_branch || @project.default_branch
......
...@@ -10,7 +10,7 @@ module Projects ...@@ -10,7 +10,7 @@ module Projects
project, project,
current_user, current_user,
{ archived: true, { archived: true,
marked_for_deletion_at: Time.now.utc, marked_for_deletion_at: Time.current.utc,
deleting_user: current_user } deleting_user: current_user }
).execute ).execute
log_event if result[:status] == :success log_event if result[:status] == :success
......
...@@ -67,7 +67,7 @@ module VulnerabilityExports ...@@ -67,7 +67,7 @@ module VulnerabilityExports
[ [
exportable.full_path.parameterize, exportable.full_path.parameterize,
'_vulnerabilities_', '_vulnerabilities_',
Time.now.utc.strftime('%FT%H%M'), Time.current.utc.strftime('%FT%H%M'),
'.', '.',
format format
].join ].join
......
...@@ -11,7 +11,7 @@ describe Ci::Minutes::BatchResetService do ...@@ -11,7 +11,7 @@ describe Ci::Minutes::BatchResetService do
id: id, id: id,
shared_runners_minutes_limit: 100, shared_runners_minutes_limit: 100,
extra_shared_runners_minutes_limit: 50, extra_shared_runners_minutes_limit: 50,
last_ci_minutes_notification_at: Time.now, last_ci_minutes_notification_at: Time.current,
last_ci_minutes_usage_notification_level: 30) last_ci_minutes_usage_notification_level: 30)
create(:namespace_statistics, namespace: namespace, shared_runners_seconds: seconds_used) create(:namespace_statistics, namespace: namespace, shared_runners_seconds: seconds_used)
......
...@@ -125,7 +125,7 @@ describe Ci::Minutes::EmailNotificationService do ...@@ -125,7 +125,7 @@ describe Ci::Minutes::EmailNotificationService do
context 'when last_ci_minutes_notification_at has a value' do context 'when last_ci_minutes_notification_at has a value' do
before do before do
namespace.update_attribute(:last_ci_minutes_notification_at, Time.now) namespace.update_attribute(:last_ci_minutes_notification_at, Time.current)
end end
it 'does not notify owners' do it 'does not notify owners' do
......
...@@ -18,7 +18,7 @@ describe ClearNamespaceSharedRunnersMinutesService do ...@@ -18,7 +18,7 @@ describe ClearNamespaceSharedRunnersMinutesService do
it 'resets timer' do it 'resets timer' do
subject subject
expect(namespace.namespace_statistics.reload.shared_runners_seconds_last_reset).to be_like_time(Time.now) expect(namespace.namespace_statistics.reload.shared_runners_seconds_last_reset).to be_like_time(Time.current)
end end
it 'successfully clears minutes' do it 'successfully clears minutes' do
......
...@@ -32,7 +32,7 @@ describe Boards::Issues::ListService, services: true do ...@@ -32,7 +32,7 @@ describe Boards::Issues::ListService, services: true do
let!(:opened_issue1) { create(:labeled_issue, project: project, milestone: m1, weight: 9, title: 'Issue 1', labels: [bug]) } let!(:opened_issue1) { create(:labeled_issue, project: project, milestone: m1, weight: 9, title: 'Issue 1', labels: [bug]) }
let!(:opened_issue2) { create(:labeled_issue, project: project, milestone: m2, weight: 1, title: 'Issue 2', labels: [p2]) } let!(:opened_issue2) { create(:labeled_issue, project: project, milestone: m2, weight: 1, title: 'Issue 2', labels: [p2]) }
let!(:opened_issue3) { create(:labeled_issue, project: project, milestone: m2, title: 'Assigned Issue', labels: [p3]) } let!(:opened_issue3) { create(:labeled_issue, project: project, milestone: m2, title: 'Assigned Issue', labels: [p3]) }
let!(:reopened_issue1) { create(:issue, state: 'opened', project: project, title: 'Issue 3', closed_at: Time.now ) } let!(:reopened_issue1) { create(:issue, state: 'opened', project: project, title: 'Issue 3', closed_at: Time.current ) }
let(:list1_issue1) { create(:labeled_issue, project: project, milestone: m1, labels: [p2, development]) } let(:list1_issue1) { create(:labeled_issue, project: project, milestone: m1, labels: [p2, development]) }
let(:list1_issue2) { create(:labeled_issue, project: project, milestone: m2, labels: [development]) } let(:list1_issue2) { create(:labeled_issue, project: project, milestone: m2, labels: [development]) }
......
...@@ -52,7 +52,7 @@ describe Issuable::CommonSystemNotesService do ...@@ -52,7 +52,7 @@ describe Issuable::CommonSystemNotesService do
end end
context 'when issuable is an epic' do context 'when issuable is an epic' do
let(:timestamp) { Time.now } let(:timestamp) { Time.current }
let(:issuable) { create(:epic, end_date: timestamp) } let(:issuable) { create(:epic, end_date: timestamp) }
subject { described_class.new(nil, user).execute(issuable, old_labels: []) } subject { described_class.new(nil, user).execute(issuable, old_labels: []) }
......
...@@ -14,7 +14,7 @@ describe EE::MergeRequestMetricsService do ...@@ -14,7 +14,7 @@ describe EE::MergeRequestMetricsService do
describe '#merge' do describe '#merge' do
let(:merge_request) { create(:merge_request, :merged) } let(:merge_request) { create(:merge_request, :merged) }
let(:expected_commit_count) { 21 } let(:expected_commit_count) { 21 }
let(:event) { instance_double('Event', author_id: merge_request.author.id, created_at: Time.now) } let(:event) { instance_double('Event', author_id: merge_request.author.id, created_at: Time.current) }
it 'saves metrics with productivity_data' do it 'saves metrics with productivity_data' do
allow(merge_request).to receive(:commits_count).and_return(expected_commit_count) allow(merge_request).to receive(:commits_count).and_return(expected_commit_count)
......
...@@ -26,7 +26,7 @@ describe ResourceEvents::MergeIntoNotesService do ...@@ -26,7 +26,7 @@ describe ResourceEvents::MergeIntoNotesService do
let_it_be(:scoped_label_group2_1) { create(:label, project: project, title: 'key2::value') } let_it_be(:scoped_label_group2_1) { create(:label, project: project, title: 'key2::value') }
let_it_be(:scoped_label_group2_2) { create(:label, project: project, title: 'key2::value2') } let_it_be(:scoped_label_group2_2) { create(:label, project: project, title: 'key2::value2') }
let_it_be(:scoped_label_group3_1) { create(:label, project: project, title: 'key3::value') } let_it_be(:scoped_label_group3_1) { create(:label, project: project, title: 'key3::value') }
let(:time) { Time.now } let(:time) { Time.current }
describe '#execute' do describe '#execute' do
it 'squashes events with same time and author into single note but scoped labels are separated' do it 'squashes events with same time and author into single note but scoped labels are separated' do
......
...@@ -73,7 +73,7 @@ describe EE::SystemNotes::EpicsService do ...@@ -73,7 +73,7 @@ describe EE::SystemNotes::EpicsService do
end end
describe '#change_epic_date_note' do describe '#change_epic_date_note' do
let(:timestamp) { Time.now } let(:timestamp) { Time.current }
context 'when start date was changed' do context 'when start date was changed' do
let(:noteable) { create(:epic) } let(:noteable) { create(:epic) }
......
...@@ -67,7 +67,7 @@ describe Geo::BlobVerificationSecondaryService, :geo do ...@@ -67,7 +67,7 @@ describe Geo::BlobVerificationSecondaryService, :geo do
expect(registry.reload).to have_attributes( expect(registry.reload).to have_attributes(
verification_checksum: '62fc1ec4ce60', verification_checksum: '62fc1ec4ce60',
checksum_mismatch: false, checksum_mismatch: false,
verified_at: be_within(1.minute).of(Time.now), verified_at: be_within(1.minute).of(Time.current),
verification_failure: nil, verification_failure: nil,
verification_retry_count: nil, verification_retry_count: nil,
retry_at: nil, retry_at: nil,
...@@ -87,7 +87,7 @@ describe Geo::BlobVerificationSecondaryService, :geo do ...@@ -87,7 +87,7 @@ describe Geo::BlobVerificationSecondaryService, :geo do
verification_checksum: nil, verification_checksum: nil,
verification_checksum_mismatched: '99fc1ec4ce60', verification_checksum_mismatched: '99fc1ec4ce60',
checksum_mismatch: true, checksum_mismatch: true,
verified_at: be_within(1.minute).of(Time.now), verified_at: be_within(1.minute).of(Time.current),
verification_failure: 'checksum mismatch', verification_failure: 'checksum mismatch',
verification_retry_count: 1, verification_retry_count: 1,
retry_at: be_present, retry_at: be_present,
...@@ -119,7 +119,7 @@ describe Geo::BlobVerificationSecondaryService, :geo do ...@@ -119,7 +119,7 @@ describe Geo::BlobVerificationSecondaryService, :geo do
verification_checksum: nil, verification_checksum: nil,
verification_checksum_mismatched: nil, verification_checksum_mismatched: nil,
checksum_mismatch: false, checksum_mismatch: false,
verified_at: be_within(1.minute).of(Time.now), verified_at: be_within(1.minute).of(Time.current),
verification_failure: 'Error calculating checksum', verification_failure: 'Error calculating checksum',
verification_retry_count: 1, verification_retry_count: 1,
retry_at: be_present, retry_at: be_present,
......
...@@ -194,7 +194,7 @@ describe Geo::FileDownloadService do ...@@ -194,7 +194,7 @@ describe Geo::FileDownloadService do
execute! execute!
expect(registry.last.reload.retry_count).to eq(1) expect(registry.last.reload.retry_count).to eq(1)
expect(registry.last.retry_at > Time.now).to be_truthy expect(registry.last.retry_at > Time.current).to be_truthy
end end
end end
end end
...@@ -223,7 +223,7 @@ describe Geo::FileDownloadService do ...@@ -223,7 +223,7 @@ describe Geo::FileDownloadService do
execute! execute!
expect(registry.last.reload.retry_count).to eq(1) expect(registry.last.reload.retry_count).to eq(1)
expect(registry.last.retry_at > Time.now).to be_truthy expect(registry.last.retry_at > Time.current).to be_truthy
end end
end end
end end
...@@ -315,7 +315,7 @@ describe Geo::FileDownloadService do ...@@ -315,7 +315,7 @@ describe Geo::FileDownloadService do
execute! execute!
expect(registry_entry.reload.retry_count).to eq(4) expect(registry_entry.reload.retry_count).to eq(4)
expect(registry_entry.retry_at > Time.now).to be_truthy expect(registry_entry.retry_at > Time.current).to be_truthy
end end
end end
...@@ -354,7 +354,7 @@ describe Geo::FileDownloadService do ...@@ -354,7 +354,7 @@ describe Geo::FileDownloadService do
execute! execute!
expect(registry_entry.reload.retry_count).to eq(4) expect(registry_entry.reload.retry_count).to eq(4)
expect(registry_entry.retry_at > Time.now).to be_truthy expect(registry_entry.retry_at > Time.current).to be_truthy
end end
end end
......
...@@ -11,7 +11,7 @@ describe Geo::MetricsUpdateService, :geo, :prometheus do ...@@ -11,7 +11,7 @@ describe Geo::MetricsUpdateService, :geo, :prometheus do
subject { described_class.new } subject { described_class.new }
let(:event_date) { Time.now.utc } let(:event_date) { Time.current.utc }
let(:data) do let(:data) do
{ {
......
...@@ -365,7 +365,7 @@ describe Geo::RepositorySyncService do ...@@ -365,7 +365,7 @@ describe Geo::RepositorySyncService do
end end
it 'successfully redownloads the repository even if the retry time exceeds max value' do it 'successfully redownloads the repository even if the retry time exceeds max value' do
timestamp = Time.now.utc timestamp = Time.current.utc
registry = create( registry = create(
:geo_project_registry, :geo_project_registry,
project: project, project: project,
......
...@@ -76,8 +76,8 @@ describe Geo::RepositoryVerificationPrimaryService do ...@@ -76,8 +76,8 @@ describe Geo::RepositoryVerificationPrimaryService do
subject.execute subject.execute
expect(project.repository_state).to have_attributes( expect(project.repository_state).to have_attributes(
last_repository_verification_ran_at: be_within(100.seconds).of(Time.now), last_repository_verification_ran_at: be_within(100.seconds).of(Time.current),
last_wiki_verification_ran_at: be_within(100.seconds).of(Time.now) last_wiki_verification_ran_at: be_within(100.seconds).of(Time.current)
) )
end end
......
...@@ -51,7 +51,7 @@ describe Geo::RepositoryVerificationSecondaryService, :geo do ...@@ -51,7 +51,7 @@ describe Geo::RepositoryVerificationSecondaryService, :geo do
expect(registry).to have_attributes( expect(registry).to have_attributes(
"#{type}_verification_checksum_sha" => '62fc1ec4ce60', "#{type}_verification_checksum_sha" => '62fc1ec4ce60',
"#{type}_checksum_mismatch" => false, "#{type}_checksum_mismatch" => false,
"last_#{type}_verification_ran_at" => be_within(1.minute).of(Time.now), "last_#{type}_verification_ran_at" => be_within(1.minute).of(Time.current),
"last_#{type}_verification_failure" => nil, "last_#{type}_verification_failure" => nil,
"#{type}_verification_retry_count" => nil, "#{type}_verification_retry_count" => nil,
"resync_#{type}" => false, "resync_#{type}" => false,
...@@ -70,7 +70,7 @@ describe Geo::RepositoryVerificationSecondaryService, :geo do ...@@ -70,7 +70,7 @@ describe Geo::RepositoryVerificationSecondaryService, :geo do
expect(registry).to have_attributes( expect(registry).to have_attributes(
"#{type}_verification_checksum_sha" => '0000000000000000000000000000000000000000', "#{type}_verification_checksum_sha" => '0000000000000000000000000000000000000000',
"#{type}_checksum_mismatch" => false, "#{type}_checksum_mismatch" => false,
"last_#{type}_verification_ran_at" => be_within(1.minute).of(Time.now), "last_#{type}_verification_ran_at" => be_within(1.minute).of(Time.current),
"last_#{type}_verification_failure" => nil, "last_#{type}_verification_failure" => nil,
"#{type}_verification_retry_count" => nil, "#{type}_verification_retry_count" => nil,
"resync_#{type}" => false, "resync_#{type}" => false,
...@@ -91,7 +91,7 @@ describe Geo::RepositoryVerificationSecondaryService, :geo do ...@@ -91,7 +91,7 @@ describe Geo::RepositoryVerificationSecondaryService, :geo do
"#{type}_verification_checksum_sha" => nil, "#{type}_verification_checksum_sha" => nil,
"#{type}_verification_checksum_mismatched" => '99fc1ec4ce60', "#{type}_verification_checksum_mismatched" => '99fc1ec4ce60',
"#{type}_checksum_mismatch" => true, "#{type}_checksum_mismatch" => true,
"last_#{type}_verification_ran_at" => be_within(1.minute).of(Time.now), "last_#{type}_verification_ran_at" => be_within(1.minute).of(Time.current),
"last_#{type}_verification_failure" => "#{type.to_s.capitalize} checksum mismatch", "last_#{type}_verification_failure" => "#{type.to_s.capitalize} checksum mismatch",
"#{type}_verification_retry_count" => 1, "#{type}_verification_retry_count" => 1,
"resync_#{type}" => true, "resync_#{type}" => true,
...@@ -125,7 +125,7 @@ describe Geo::RepositoryVerificationSecondaryService, :geo do ...@@ -125,7 +125,7 @@ describe Geo::RepositoryVerificationSecondaryService, :geo do
"#{type}_verification_checksum_sha" => nil, "#{type}_verification_checksum_sha" => nil,
"#{type}_verification_checksum_mismatched" => nil, "#{type}_verification_checksum_mismatched" => nil,
"#{type}_checksum_mismatch" => false, "#{type}_checksum_mismatch" => false,
"last_#{type}_verification_ran_at" => be_within(1.minute).of(Time.now), "last_#{type}_verification_ran_at" => be_within(1.minute).of(Time.current),
"last_#{type}_verification_failure" => "Error calculating #{type} checksum", "last_#{type}_verification_failure" => "Error calculating #{type} checksum",
"#{type}_verification_retry_count" => 1, "#{type}_verification_retry_count" => 1,
"resync_#{type}" => true, "resync_#{type}" => true,
......
...@@ -6,8 +6,8 @@ describe LdapGroupResetService do ...@@ -6,8 +6,8 @@ describe LdapGroupResetService do
# TODO: refactor to multi-ldap setup # TODO: refactor to multi-ldap setup
let(:group) { create(:group) } let(:group) { create(:group) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:ldap_user) { create(:omniauth_user, extern_uid: 'john', provider: 'ldap', last_credential_check_at: Time.now) } let(:ldap_user) { create(:omniauth_user, extern_uid: 'john', provider: 'ldap', last_credential_check_at: Time.current) }
let(:ldap_user_2) { create(:omniauth_user, extern_uid: 'mike', provider: 'ldap', last_credential_check_at: Time.now) } let(:ldap_user_2) { create(:omniauth_user, extern_uid: 'mike', provider: 'ldap', last_credential_check_at: Time.current) }
before do before do
group.add_owner(user) group.add_owner(user)
......
...@@ -226,7 +226,7 @@ describe Security::WafAnomalySummaryService do ...@@ -226,7 +226,7 @@ describe Security::WafAnomalySummaryService do
context 'with time window' do context 'with time window' do
it 'passes time frame to ElasticSearch' do it 'passes time frame to ElasticSearch' do
from = 1.day.ago from = 1.day.ago
to = Time.now to = Time.current
subject = described_class.new( subject = described_class.new(
environment: environment, environment: environment,
......
...@@ -103,7 +103,7 @@ describe VulnerabilityExports::ExportService do ...@@ -103,7 +103,7 @@ describe VulnerabilityExports::ExportService do
let(:mock_relation) { double(:relation, with_findings_and_scanner: vulnerabilities) } let(:mock_relation) { double(:relation, with_findings_and_scanner: vulnerabilities) }
let(:mock_vulnerability_finder_service_object) { instance_double(Security::VulnerabilitiesFinder, execute: mock_relation) } let(:mock_vulnerability_finder_service_object) { instance_double(Security::VulnerabilitiesFinder, execute: mock_relation) }
let(:exportable_full_path) { 'foo' } let(:exportable_full_path) { 'foo' }
let(:time_suffix) { Time.now.utc.strftime('%FT%H%M') } let(:time_suffix) { Time.current.utc.strftime('%FT%H%M') }
let(:expected_file_name) { "#{exportable_full_path}_vulnerabilities_#{time_suffix}.csv" } let(:expected_file_name) { "#{exportable_full_path}_vulnerabilities_#{time_suffix}.csv" }
before do before do
......
...@@ -39,7 +39,7 @@ describe Auth::ContainerRegistryAuthenticationService do ...@@ -39,7 +39,7 @@ describe Auth::ContainerRegistryAuthenticationService do
let(:expire_delay) { 10 } let(:expire_delay) { 10 }
context 'for default configuration' do context 'for default configuration' do
it { expect(expires_at).not_to be_within(2.seconds).of(Time.now + expire_delay.minutes) } it { expect(expires_at).not_to be_within(2.seconds).of(Time.current + expire_delay.minutes) }
end end
context 'for changed configuration' do context 'for changed configuration' do
...@@ -47,7 +47,7 @@ describe Auth::ContainerRegistryAuthenticationService do ...@@ -47,7 +47,7 @@ describe Auth::ContainerRegistryAuthenticationService do
stub_application_setting(container_registry_token_expire_delay: expire_delay) stub_application_setting(container_registry_token_expire_delay: expire_delay)
end end
it { expect(expires_at).to be_within(2.seconds).of(Time.now + expire_delay.minutes) } it { expect(expires_at).to be_within(2.seconds).of(Time.current + expire_delay.minutes) }
end end
end end
end end
......
...@@ -87,7 +87,7 @@ describe Boards::Issues::ListService do ...@@ -87,7 +87,7 @@ describe Boards::Issues::ListService do
let!(:opened_issue1) { create(:labeled_issue, project: project, milestone: m1, title: 'Issue 1', labels: [bug]) } let!(:opened_issue1) { create(:labeled_issue, project: project, milestone: m1, title: 'Issue 1', labels: [bug]) }
let!(:opened_issue2) { create(:labeled_issue, project: project, milestone: m2, title: 'Issue 2', labels: [p2, p2_project]) } let!(:opened_issue2) { create(:labeled_issue, project: project, milestone: m2, title: 'Issue 2', labels: [p2, p2_project]) }
let!(:opened_issue3) { create(:labeled_issue, project: project_archived, milestone: m1, title: 'Issue 3', labels: [bug]) } let!(:opened_issue3) { create(:labeled_issue, project: project_archived, milestone: m1, title: 'Issue 3', labels: [bug]) }
let!(:reopened_issue1) { create(:issue, state: 'opened', project: project, title: 'Reopened Issue 1', closed_at: Time.now ) } let!(:reopened_issue1) { create(:issue, state: 'opened', project: project, title: 'Reopened Issue 1', closed_at: Time.current ) }
let!(:list1_issue1) { create(:labeled_issue, project: project, milestone: m1, labels: [p2, p2_project, development]) } let!(:list1_issue1) { create(:labeled_issue, project: project, milestone: m1, labels: [p2, p2_project, development]) }
let!(:list1_issue2) { create(:labeled_issue, project: project, milestone: m2, labels: [development]) } let!(:list1_issue2) { create(:labeled_issue, project: project, milestone: m2, labels: [development]) }
......
...@@ -13,10 +13,10 @@ describe Clusters::Applications::ScheduleUpdateService do ...@@ -13,10 +13,10 @@ describe Clusters::Applications::ScheduleUpdateService do
context 'when application is able to be updated' do context 'when application is able to be updated' do
context 'when the application was recently scheduled' do context 'when the application was recently scheduled' do
it 'schedules worker with a backoff delay' do it 'schedules worker with a backoff delay' do
application = create(:clusters_applications_prometheus, :installed, last_update_started_at: Time.now + 5.minutes) application = create(:clusters_applications_prometheus, :installed, last_update_started_at: Time.current + 5.minutes)
service = described_class.new(application, project) service = described_class.new(application, project)
expect(::ClusterUpdateAppWorker).to receive(:perform_in).with(described_class::BACKOFF_DELAY, application.name, application.id, project.id, Time.now).once expect(::ClusterUpdateAppWorker).to receive(:perform_in).with(described_class::BACKOFF_DELAY, application.name, application.id, project.id, Time.current).once
service.execute service.execute
end end
...@@ -27,7 +27,7 @@ describe Clusters::Applications::ScheduleUpdateService do ...@@ -27,7 +27,7 @@ describe Clusters::Applications::ScheduleUpdateService do
application = create(:clusters_applications_prometheus, :installed) application = create(:clusters_applications_prometheus, :installed)
service = described_class.new(application, project) service = described_class.new(application, project)
expect(::ClusterUpdateAppWorker).to receive(:perform_async).with(application.name, application.id, project.id, Time.now).once expect(::ClusterUpdateAppWorker).to receive(:perform_async).with(application.name, application.id, project.id, Time.current).once
service.execute service.execute
end end
......
...@@ -120,8 +120,8 @@ describe Clusters::Kubernetes::ConfigureIstioIngressService, '#execute' do ...@@ -120,8 +120,8 @@ describe Clusters::Kubernetes::ConfigureIstioIngressService, '#execute' do
expect(certificate.subject.to_s).to include(serverless_domain_cluster.knative.hostname) expect(certificate.subject.to_s).to include(serverless_domain_cluster.knative.hostname)
expect(certificate.not_before).to be_within(1.minute).of(Time.now) expect(certificate.not_before).to be_within(1.minute).of(Time.current)
expect(certificate.not_after).to be_within(1.minute).of(Time.now + 1000.years) expect(certificate.not_after).to be_within(1.minute).of(Time.current + 1000.years)
expect(WebMock).to have_requested(:put, api_url + '/api/v1/namespaces/istio-system/secrets/istio-ingressgateway-ca-certs').with( expect(WebMock).to have_requested(:put, api_url + '/api/v1/namespaces/istio-system/secrets/istio-ingressgateway-ca-certs').with(
body: hash_including( body: hash_including(
......
...@@ -13,7 +13,7 @@ describe CohortsService do ...@@ -13,7 +13,7 @@ describe CohortsService do
6.times do |months_ago| 6.times do |months_ago|
months_ago_time = (months_ago * 2).months.ago months_ago_time = (months_ago * 2).months.ago
create(:user, created_at: months_ago_time, last_activity_on: Time.now) create(:user, created_at: months_ago_time, last_activity_on: Time.current)
create(:user, created_at: months_ago_time, last_activity_on: months_ago_time) create(:user, created_at: months_ago_time, last_activity_on: months_ago_time)
end end
......
...@@ -315,7 +315,7 @@ describe Git::BranchPushService, services: true do ...@@ -315,7 +315,7 @@ describe Git::BranchPushService, services: true do
let(:issue) { create :issue, project: project } let(:issue) { create :issue, project: project }
let(:commit_author) { create :user } let(:commit_author) { create :user }
let(:commit) { project.commit } let(:commit) { project.commit }
let(:commit_time) { Time.now } let(:commit_time) { Time.current }
before do before do
project.add_developer(commit_author) project.add_developer(commit_author)
......
...@@ -6,7 +6,7 @@ describe IncidentManagement::CreateIssueService do ...@@ -6,7 +6,7 @@ describe IncidentManagement::CreateIssueService do
let(:project) { create(:project, :repository, :private) } let(:project) { create(:project, :repository, :private) }
let_it_be(:user) { User.alert_bot } let_it_be(:user) { User.alert_bot }
let(:service) { described_class.new(project, alert_payload) } let(:service) { described_class.new(project, alert_payload) }
let(:alert_starts_at) { Time.now } let(:alert_starts_at) { Time.current }
let(:alert_title) { 'TITLE' } let(:alert_title) { 'TITLE' }
let(:alert_annotations) { { title: alert_title } } let(:alert_annotations) { { title: alert_title } }
...@@ -302,7 +302,7 @@ describe IncidentManagement::CreateIssueService do ...@@ -302,7 +302,7 @@ describe IncidentManagement::CreateIssueService do
private private
def build_alert_payload(annotations: {}, starts_at: Time.now) def build_alert_payload(annotations: {}, starts_at: Time.current)
{ {
'annotations' => annotations.stringify_keys 'annotations' => annotations.stringify_keys
}.tap do |payload| }.tap do |payload|
......
...@@ -146,7 +146,7 @@ describe Issues::CloseService do ...@@ -146,7 +146,7 @@ describe Issues::CloseService do
context 'when `metrics.first_mentioned_in_commit_at` is already set' do context 'when `metrics.first_mentioned_in_commit_at` is already set' do
before do before do
issue.metrics.update!(first_mentioned_in_commit_at: Time.now) issue.metrics.update!(first_mentioned_in_commit_at: Time.current)
end end
it 'does not update the metrics' do it 'does not update the metrics' do
......
...@@ -510,7 +510,7 @@ describe Issues::UpdateService, :mailer do ...@@ -510,7 +510,7 @@ describe Issues::UpdateService, :mailer do
end end
it 'updates updated_at' do it 'updates updated_at' do
expect(issue.reload.updated_at).to be > Time.now expect(issue.reload.updated_at).to be > Time.current
end end
end end
end end
......
...@@ -118,7 +118,7 @@ describe MergeRequests::MergeService do ...@@ -118,7 +118,7 @@ describe MergeRequests::MergeService do
it 'closes GitLab issue tracker issues' do it 'closes GitLab issue tracker issues' do
issue = create :issue, project: project issue = create :issue, project: project
commit = instance_double('commit', safe_message: "Fixes #{issue.to_reference}", date: Time.now, authored_date: Time.now) commit = instance_double('commit', safe_message: "Fixes #{issue.to_reference}", date: Time.current, authored_date: Time.current)
allow(merge_request).to receive(:commits).and_return([commit]) allow(merge_request).to receive(:commits).and_return([commit])
merge_request.cache_merge_request_closes_issues! merge_request.cache_merge_request_closes_issues!
......
...@@ -635,7 +635,7 @@ describe MergeRequests::RefreshService do ...@@ -635,7 +635,7 @@ describe MergeRequests::RefreshService do
references: [issue], references: [issue],
author_name: commit_author.name, author_name: commit_author.name,
author_email: commit_author.email, author_email: commit_author.email,
committed_date: Time.now committed_date: Time.current
) )
allow_any_instance_of(MergeRequest).to receive(:commits).and_return(CommitCollection.new(@project, [commit], 'feature')) allow_any_instance_of(MergeRequest).to receive(:commits).and_return(CommitCollection.new(@project, [commit], 'feature'))
......
...@@ -453,7 +453,7 @@ describe MergeRequests::UpdateService, :mailer do ...@@ -453,7 +453,7 @@ describe MergeRequests::UpdateService, :mailer do
end end
it 'updates updated_at' do it 'updates updated_at' do
expect(merge_request.reload.updated_at).to be > Time.now expect(merge_request.reload.updated_at).to be > Time.current
end end
end end
......
...@@ -25,7 +25,7 @@ describe NoteSummary do ...@@ -25,7 +25,7 @@ describe NoteSummary do
it 'returns note hash' do it 'returns note hash' do
Timecop.freeze do Timecop.freeze 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.now) created_at: Time.current)
end end
end end
......
...@@ -425,7 +425,7 @@ describe Notes::CreateService do ...@@ -425,7 +425,7 @@ describe Notes::CreateService do
expect do expect do
existing_note existing_note
Timecop.freeze(Time.now + 1.minute) { subject } Timecop.freeze(Time.current + 1.minute) { subject }
existing_note.reload existing_note.reload
end.to change { existing_note.type }.from(nil).to('DiscussionNote') end.to change { existing_note.type }.from(nil).to('DiscussionNote')
......
...@@ -119,7 +119,7 @@ describe PagesDomains::ObtainLetsEncryptCertificateService do ...@@ -119,7 +119,7 @@ describe PagesDomains::ObtainLetsEncryptCertificateService do
cert = OpenSSL::X509::Certificate.new cert = OpenSSL::X509::Certificate.new
cert.subject = cert.issuer = OpenSSL::X509::Name.parse(subject) cert.subject = cert.issuer = OpenSSL::X509::Name.parse(subject)
cert.not_before = Time.now cert.not_before = Time.current
cert.not_after = 1.year.from_now cert.not_after = 1.year.from_now
cert.public_key = key.public_key cert.public_key = key.public_key
cert.serial = 0x0 cert.serial = 0x0
......
...@@ -72,7 +72,7 @@ describe Projects::Alerting::NotifyService do ...@@ -72,7 +72,7 @@ describe Projects::Alerting::NotifyService do
describe '#execute' do describe '#execute' do
let(:token) { 'invalid-token' } let(:token) { 'invalid-token' }
let(:starts_at) { Time.now.change(usec: 0) } let(:starts_at) { Time.current.change(usec: 0) }
let(:service) { described_class.new(project, nil, payload) } let(:service) { described_class.new(project, nil, payload) }
let(:payload_raw) do let(:payload_raw) do
{ {
......
...@@ -31,7 +31,7 @@ describe Projects::HashedStorage::BaseAttachmentService do ...@@ -31,7 +31,7 @@ describe Projects::HashedStorage::BaseAttachmentService do
expect(Dir.exist?(target_path)).to be_truthy expect(Dir.exist?(target_path)).to be_truthy
Timecop.freeze do Timecop.freeze do
suffix = Time.now.utc.to_i suffix = Time.current.utc.to_i
subject.send(:discard_path!, target_path) subject.send(:discard_path!, target_path)
expected_renamed_path = "#{target_path}-#{suffix}" expected_renamed_path = "#{target_path}-#{suffix}"
......
...@@ -50,7 +50,7 @@ describe Projects::Prometheus::Alerts::CreateEventsService do ...@@ -50,7 +50,7 @@ describe Projects::Prometheus::Alerts::CreateEventsService do
let(:events) { service.execute } let(:events) { service.execute }
context 'with a firing payload' do context 'with a firing payload' do
let(:started_at) { truncate_to_second(Time.now) } let(:started_at) { truncate_to_second(Time.current) }
let(:firing_event) { alert_payload(status: 'firing', started_at: started_at) } let(:firing_event) { alert_payload(status: 'firing', started_at: started_at) }
let(:alerts_payload) { { 'alerts' => [firing_event] } } let(:alerts_payload) { { 'alerts' => [firing_event] } }
...@@ -87,7 +87,7 @@ describe Projects::Prometheus::Alerts::CreateEventsService do ...@@ -87,7 +87,7 @@ describe Projects::Prometheus::Alerts::CreateEventsService do
end end
context 'with a resolved payload' do context 'with a resolved payload' do
let(:started_at) { truncate_to_second(Time.now) } let(:started_at) { truncate_to_second(Time.current) }
let(:ended_at) { started_at + 1 } let(:ended_at) { started_at + 1 }
let(:payload_key) { PrometheusAlertEvent.payload_key_for(alert.prometheus_metric_id, utc_rfc3339(started_at)) } let(:payload_key) { PrometheusAlertEvent.payload_key_for(alert.prometheus_metric_id, utc_rfc3339(started_at)) }
let(:resolved_event) { alert_payload(status: 'resolved', started_at: started_at, ended_at: ended_at) } let(:resolved_event) { alert_payload(status: 'resolved', started_at: started_at, ended_at: ended_at) }
...@@ -285,7 +285,7 @@ describe Projects::Prometheus::Alerts::CreateEventsService do ...@@ -285,7 +285,7 @@ describe Projects::Prometheus::Alerts::CreateEventsService do
private private
def alert_payload(status: 'firing', started_at: Time.now, ended_at: Time.now, gitlab_alert_id: alert.prometheus_metric_id, title: nil, environment: nil) def alert_payload(status: 'firing', started_at: Time.current, ended_at: Time.current, gitlab_alert_id: alert.prometheus_metric_id, title: nil, environment: nil)
payload = {} payload = {}
payload['status'] = status if status payload['status'] = status if status
......
...@@ -8,7 +8,7 @@ describe Projects::UpdateRepositoryStorageService do ...@@ -8,7 +8,7 @@ describe Projects::UpdateRepositoryStorageService do
subject { described_class.new(repository_storage_move) } subject { described_class.new(repository_storage_move) }
describe "#execute" do describe "#execute" do
let(:time) { Time.now } let(:time) { Time.current }
before do before do
allow(Time).to receive(:now).and_return(time) allow(Time).to receive(:now).and_return(time)
......
...@@ -361,7 +361,7 @@ describe QuickActions::InterpretService do ...@@ -361,7 +361,7 @@ describe QuickActions::InterpretService do
expect(updates).to eq(spend_time: { expect(updates).to eq(spend_time: {
duration: 3600, duration: 3600,
user_id: developer.id, user_id: developer.id,
spent_at: DateTime.now.to_date spent_at: DateTime.current.to_date
}) })
end end
...@@ -379,7 +379,7 @@ describe QuickActions::InterpretService do ...@@ -379,7 +379,7 @@ describe QuickActions::InterpretService do
expect(updates).to eq(spend_time: { expect(updates).to eq(spend_time: {
duration: -1800, duration: -1800,
user_id: developer.id, user_id: developer.id,
spent_at: DateTime.now.to_date spent_at: DateTime.current.to_date
}) })
end end
end end
......
...@@ -110,6 +110,6 @@ describe RepositoryArchiveCleanUpService do ...@@ -110,6 +110,6 @@ describe RepositoryArchiveCleanUpService do
def create_temporary_files(dir, extensions, mtime) def create_temporary_files(dir, extensions, mtime)
FileUtils.mkdir_p(dir) FileUtils.mkdir_p(dir)
FileUtils.touch(extensions.map { |ext| File.join(dir, "sample.#{ext}") }, mtime: Time.now - mtime) FileUtils.touch(extensions.map { |ext| File.join(dir, "sample.#{ext}") }, mtime: Time.current - mtime)
end end
end end
...@@ -21,7 +21,7 @@ describe ResourceEvents::MergeIntoNotesService do ...@@ -21,7 +21,7 @@ describe ResourceEvents::MergeIntoNotesService do
let_it_be(:resource) { create(:issue, project: project) } let_it_be(:resource) { create(:issue, project: project) }
let_it_be(:label) { create(:label, project: project) } let_it_be(:label) { create(:label, project: project) }
let_it_be(:label2) { create(:label, project: project) } let_it_be(:label2) { create(:label, project: project) }
let(:time) { Time.now } let(:time) { Time.current }
describe '#execute' do describe '#execute' do
it 'merges label events into notes in order of created_at' do it 'merges label events into notes in order of created_at' do
......
...@@ -9,7 +9,7 @@ describe MergeRequestMetricsService do ...@@ -9,7 +9,7 @@ describe MergeRequestMetricsService do
it 'updates metrics' do it 'updates metrics' do
user = create(:user) user = create(:user)
service = described_class.new(metrics) service = described_class.new(metrics)
event = double(Event, author_id: user.id, created_at: Time.now) event = double(Event, author_id: user.id, created_at: Time.current)
service.merge(event) service.merge(event)
...@@ -22,7 +22,7 @@ describe MergeRequestMetricsService do ...@@ -22,7 +22,7 @@ describe MergeRequestMetricsService do
it 'updates metrics' do it 'updates metrics' do
user = create(:user) user = create(:user)
service = described_class.new(metrics) service = described_class.new(metrics)
event = double(Event, author_id: user.id, created_at: Time.now) event = double(Event, author_id: user.id, created_at: Time.current)
service.close(event) service.close(event)
......
...@@ -348,7 +348,7 @@ describe VerifyPagesDomainService do ...@@ -348,7 +348,7 @@ describe VerifyPagesDomainService do
end end
it 'does not shorten any grace period' do it 'does not shorten any grace period' do
grace = Time.now + 1.year grace = Time.current + 1.year
domain.update!(enabled_until: grace) domain.update!(enabled_until: grace)
disallow_resolver! disallow_resolver!
......
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