Commit dcbf99d1 authored by Sean Arnold's avatar Sean Arnold

Move user facing code to use Time.current

parent 8a58f927
......@@ -48,7 +48,7 @@ module Gitlab
def initialize(params = {})
super(params)
self.created_before = (self.created_before || Time.now).at_end_of_day
self.created_before = (self.created_before || Time.current).at_end_of_day
self.created_after = (created_after || default_created_after).at_beginning_of_day
end
......
......@@ -21,7 +21,7 @@ module Gitlab
def value
@value ||=
frequency(@deployments, options[:from], options[:to] || Time.now)
frequency(@deployments, options[:from], options[:to] || Time.current)
end
def unit
......
......@@ -218,7 +218,7 @@ module API
user_params = declared_params(include_missing: false)
user_params[:password_expires_at] = Time.now if user_params[:password].present?
user_params[:password_expires_at] = Time.current if user_params[:password].present?
result = ::Users::UpdateService.new(current_user, user_params.merge(user: user)).execute
if result[:status] == :success
......
......@@ -32,7 +32,7 @@ module Gitlab
end
def incident_created_at
Time.parse(incident_payload['created_at'])
Time.zone.parse(incident_payload['created_at'])
rescue
Time.current.utc # PagerDuty provides time in UTC
end
......
......@@ -58,7 +58,7 @@ module Gitlab
end
def recorded_at
Time.now
Time.current
end
# rubocop: disable Metrics/AbcSize
......
......@@ -93,7 +93,7 @@ module Gitlab
end
def with_finished_at(key, &block)
yield.merge(key => Time.now)
yield.merge(key => Time.current)
end
private
......
......@@ -191,7 +191,7 @@ RSpec.describe Gitlab::Alerting::Alert do
end
context 'with payload' do
let(:time) { Time.now.change(usec: 0) }
let(:time) { Time.current.change(usec: 0) }
before do
payload['startsAt'] = time.rfc3339
......@@ -274,7 +274,7 @@ RSpec.describe Gitlab::Alerting::Alert do
before do
payload.update(
'annotations' => { 'title' => 'some title' },
'startsAt' => Time.now.rfc3339
'startsAt' => Time.current.rfc3339
)
end
......
......@@ -122,7 +122,7 @@ RSpec.describe Gitlab::Utils::UsageData do
freeze_time do
result = described_class.with_finished_at(:current_time) { { a: 1 } }
expect(result).to eq(a: 1, current_time: Time.now)
expect(result).to eq(a: 1, current_time: Time.current)
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment