Commit 4c0f6a93 authored by Stan Hu's avatar Stan Hu

Merge branch '216527-time-zone-usage-controllers' into 'master'

Time.now => Time.current in controllers

See merge request gitlab-org/gitlab!31578
parents 81a1e155 ced4f681
......@@ -145,7 +145,7 @@ class Admin::UsersController < Admin::ApplicationController
password_confirmation: params[:user][:password_confirmation]
}
password_params[:password_expires_at] = Time.now unless changing_own_password?
password_params[:password_expires_at] = Time.current unless changing_own_password?
user_params_with_pass.merge!(password_params)
end
......
......@@ -13,7 +13,7 @@ module NotesActions
end
def index
current_fetched_at = Time.now.to_i
current_fetched_at = Time.current.to_i
notes_json = { notes: [], last_fetched_at: current_fetched_at }
......
......@@ -5,7 +5,7 @@ class UserCalloutsController < ApplicationController
callout = ensure_callout
if callout.persisted?
callout.update(dismissed_at: Time.now)
callout.update(dismissed_at: Time.current)
respond_to do |format|
format.json { head :ok }
end
......
......@@ -34,7 +34,7 @@ module EE
if result[:status] == :success
redirect_to group_path(group),
status: :found,
notice: "'#{group.name}' has been scheduled for removal on #{permanent_deletion_date(Time.now.utc)}."
notice: "'#{group.name}' has been scheduled for removal on #{permanent_deletion_date(Time.current.utc)}."
else
redirect_to edit_group_path(group), status: :found, alert: result[:message]
end
......
......@@ -90,7 +90,7 @@ module EE
# If the known hosts data is being set, store details about who and when
if import_data[:ssh_known_hosts].present?
import_data[:ssh_known_hosts_verified_at] = Time.now
import_data[:ssh_known_hosts_verified_at] = Time.current
import_data[:ssh_known_hosts_verified_by_id] = current_user.id
end
end
......
......@@ -18,7 +18,7 @@ module Projects
:packet_flow, environment.deployment_namespace,
params[:interval] || "minute",
(Time.parse(params[:from]) rescue 1.hour.ago).to_s,
(Time.parse(params[:to]) rescue Time.now).to_s
(Time.parse(params[:to]) rescue Time.current).to_s
)
respond_to do |format|
......
......@@ -240,7 +240,7 @@ describe Admin::ApplicationSettingsController do
end
context 'when an admin user attempts a request' do
let_it_be(:yesterday) { Time.now.utc.yesterday.to_date }
let_it_be(:yesterday) { Time.current.utc.yesterday.to_date }
let_it_be(:max_count) { 15 }
let_it_be(:current_count) { 10 }
......
......@@ -220,7 +220,7 @@ describe Analytics::CycleAnalytics::StagesController do
subject { get :duration_chart, params: params }
it 'matches the response schema' do
fake_result = [double(MergeRequest, duration_in_seconds: 10, finished_at: Time.now)]
fake_result = [double(MergeRequest, duration_in_seconds: 10, finished_at: Time.current)]
expect_any_instance_of(Gitlab::Analytics::CycleAnalytics::DataForDurationChart).to receive(:load).and_return(fake_result)
subject
......
......@@ -220,7 +220,7 @@ describe Groups::Analytics::CycleAnalytics::StagesController do
subject { get :duration_chart, params: params }
it 'matches the response schema' do
fake_result = [double(MergeRequest, duration_in_seconds: 10, finished_at: Time.now)]
fake_result = [double(MergeRequest, duration_in_seconds: 10, finished_at: Time.current)]
expect_any_instance_of(Gitlab::Analytics::CycleAnalytics::DataForDurationChart).to receive(:load).and_return(fake_result)
subject
......
......@@ -19,7 +19,7 @@ describe Groups::ContributionAnalyticsController do
action: action,
target: target,
author: author,
created_at: Time.now)
created_at: Time.current)
end
def create_push_event(author, project)
......
......@@ -366,7 +366,7 @@ describe Groups::EpicsController do
context 'when state_event param is reopen' do
before do
epic.update!(state: 'closed', closed_at: Time.now, closed_by: user)
epic.update!(state: 'closed', closed_at: Time.current, closed_by: user)
end
it 'allows epic to be reopened' do
......
......@@ -73,7 +73,7 @@ describe OperationsController do
end
describe 'GET #list' do
let(:now) { Time.now.change(usec: 0) }
let(:now) { Time.current.change(usec: 0) }
let(:project) { create(:project, :repository) }
let(:commit) { project.commit }
let!(:environment) { create(:environment, name: 'production', project: project) }
......
......@@ -18,7 +18,7 @@ describe Projects::BranchesController do
render_views
before do
create(:import_state, :mirror, :finished, project: project, last_successful_update_at: Time.now)
create(:import_state, :mirror, :finished, project: project, last_successful_update_at: Time.current)
allow(project.repository).to receive(:diverged_from_upstream?) { true }
end
......
......@@ -172,7 +172,7 @@ describe Projects::MirrorsController do
expect(response).to have_gitlab_http_status(:ok)
import_data = project.reload_import_data
expect(import_data.ssh_known_hosts_verified_at).to be_within(1.minute).of(Time.now)
expect(import_data.ssh_known_hosts_verified_at).to be_within(1.minute).of(Time.current)
expect(import_data.ssh_known_hosts_verified_by).to eq(project.owner)
end
......
......@@ -40,7 +40,7 @@ describe Projects::Security::NetworkPoliciesController do
Timecop.freeze do
expect(adapter).to(
receive(:query)
.with(:packet_flow, kubernetes_namespace, "minute", 1.hour.ago.to_s, Time.now.to_s)
.with(:packet_flow, kubernetes_namespace, "minute", 1.hour.ago.to_s, Time.current.to_s)
.and_return({ success: true, data: { ops_rate: [[Time.at(0).to_i, 10]], ops_total: 10 } })
)
subject
......@@ -81,7 +81,7 @@ describe Projects::Security::NetworkPoliciesController do
Timecop.freeze do
expect(adapter).to(
receive(:query)
.with(:packet_flow, kubernetes_namespace, "minute", 1.hour.ago.to_s, Time.now.to_s)
.with(:packet_flow, kubernetes_namespace, "minute", 1.hour.ago.to_s, Time.current.to_s)
.and_return({ success: true, data: {} })
)
subject
......
......@@ -27,7 +27,7 @@ describe Admin::RequestsProfilesController do
end
context 'when loading HTML profile' do
let(:basename) { "profile_#{Time.now.to_i}_execution.html" }
let(:basename) { "profile_#{Time.current.to_i}_execution.html" }
let(:sample_data) do
'<html> <body> <h1>Heading</h1> <p>paragraph.</p> </body> </html>'
......@@ -42,7 +42,7 @@ describe Admin::RequestsProfilesController do
end
context 'when loading TXT profile' do
let(:basename) { "profile_#{Time.now.to_i}_memory.txt" }
let(:basename) { "profile_#{Time.current.to_i}_memory.txt" }
let(:sample_data) do
<<~TXT
......@@ -60,7 +60,7 @@ describe Admin::RequestsProfilesController do
end
context 'when loading PDF profile' do
let(:basename) { "profile_#{Time.now.to_i}_anything.pdf" }
let(:basename) { "profile_#{Time.current.to_i}_anything.pdf" }
let(:sample_data) { 'mocked pdf content' }
......
......@@ -296,7 +296,7 @@ describe Admin::UsersController do
it 'sets the new password to expire immediately' do
expect { update_password(user, 'AValidPassword1') }
.to change { user.reload.password_expires_at }.to be_within(2.seconds).of(Time.now)
.to change { user.reload.password_expires_at }.to be_within(2.seconds).of(Time.current)
end
end
......
......@@ -25,7 +25,7 @@ describe ApplicationController do
end
it 'does not redirect if the user is under their password expiry' do
user.password_expires_at = Time.now + 20010101
user.password_expires_at = Time.current + 20010101
expect(user.ldap_user?).to be_falsey
allow(controller).to receive(:current_user).and_return(user)
......
......@@ -27,7 +27,7 @@ describe Import::BitbucketController do
end
it "updates access token" do
expires_at = Time.now + 1.day
expires_at = Time.current + 1.day
expires_in = 1.day
access_token = double(token: token,
secret: secret,
......
......@@ -609,7 +609,7 @@ describe Projects::IssuesController do
before do
project.add_developer(user)
issue.update!(last_edited_by: deleted_user, last_edited_at: Time.now)
issue.update!(last_edited_by: deleted_user, last_edited_at: Time.current)
deleted_user.destroy
sign_in(user)
......
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