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 ...@@ -48,7 +48,7 @@ module Gitlab
def initialize(params = {}) def initialize(params = {})
super(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 self.created_after = (created_after || default_created_after).at_beginning_of_day
end end
......
...@@ -21,7 +21,7 @@ module Gitlab ...@@ -21,7 +21,7 @@ module Gitlab
def value def value
@value ||= @value ||=
frequency(@deployments, options[:from], options[:to] || Time.now) frequency(@deployments, options[:from], options[:to] || Time.current)
end end
def unit def unit
......
...@@ -218,7 +218,7 @@ module API ...@@ -218,7 +218,7 @@ module API
user_params = declared_params(include_missing: false) 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 result = ::Users::UpdateService.new(current_user, user_params.merge(user: user)).execute
if result[:status] == :success if result[:status] == :success
......
...@@ -32,7 +32,7 @@ module Gitlab ...@@ -32,7 +32,7 @@ module Gitlab
end end
def incident_created_at def incident_created_at
Time.parse(incident_payload['created_at']) Time.zone.parse(incident_payload['created_at'])
rescue rescue
Time.current.utc # PagerDuty provides time in UTC Time.current.utc # PagerDuty provides time in UTC
end end
......
...@@ -58,7 +58,7 @@ module Gitlab ...@@ -58,7 +58,7 @@ module Gitlab
end end
def recorded_at def recorded_at
Time.now Time.current
end end
# rubocop: disable Metrics/AbcSize # rubocop: disable Metrics/AbcSize
......
...@@ -93,7 +93,7 @@ module Gitlab ...@@ -93,7 +93,7 @@ module Gitlab
end end
def with_finished_at(key, &block) def with_finished_at(key, &block)
yield.merge(key => Time.now) yield.merge(key => Time.current)
end end
private private
......
...@@ -191,7 +191,7 @@ RSpec.describe Gitlab::Alerting::Alert do ...@@ -191,7 +191,7 @@ RSpec.describe Gitlab::Alerting::Alert do
end end
context 'with payload' do context 'with payload' do
let(:time) { Time.now.change(usec: 0) } let(:time) { Time.current.change(usec: 0) }
before do before do
payload['startsAt'] = time.rfc3339 payload['startsAt'] = time.rfc3339
...@@ -274,7 +274,7 @@ RSpec.describe Gitlab::Alerting::Alert do ...@@ -274,7 +274,7 @@ RSpec.describe Gitlab::Alerting::Alert do
before do before do
payload.update( payload.update(
'annotations' => { 'title' => 'some title' }, 'annotations' => { 'title' => 'some title' },
'startsAt' => Time.now.rfc3339 'startsAt' => Time.current.rfc3339
) )
end end
......
...@@ -122,7 +122,7 @@ RSpec.describe Gitlab::Utils::UsageData do ...@@ -122,7 +122,7 @@ RSpec.describe Gitlab::Utils::UsageData do
freeze_time do freeze_time do
result = described_class.with_finished_at(:current_time) { { a: 1 } } 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 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