Enforce Timezone rule in Rubocop

This commit is contained in:
Mathieu Magnin 2019-02-18 11:56:09 +01:00
parent 995e189637
commit dd27167c5d
6 changed files with 6 additions and 6 deletions

View file

@ -777,7 +777,7 @@ Rails/SkipsModelValidations:
Enabled: false
Rails/TimeZone:
Enabled: true
EnforcedStyle: strict
Rails/UniqBeforePluck:
Enabled: true

View file

@ -34,7 +34,7 @@ class Users::ConfirmationsController < Devise::ConfirmationsController
# Avoid keeping auto-sign-in links in users inboxes for too long.
# 95% of users confirm their account within two hours.
auto_sign_in_timeout = 2.hours
resource.confirmation_sent_at + auto_sign_in_timeout > DateTime.current
resource.confirmation_sent_at + auto_sign_in_timeout > Time.zone.now
end
# The path used after confirmation.

View file

@ -2,6 +2,6 @@ class DeletedDossier < ApplicationRecord
belongs_to :procedure
def self.create_from_dossier(dossier)
DeletedDossier.create!(dossier_id: dossier.id, procedure: dossier.procedure, state: dossier.state, deleted_at: Time.now.utc)
DeletedDossier.create!(dossier_id: dossier.id, procedure: dossier.procedure, state: dossier.state, deleted_at: Time.zone.now)
end
end

View file

@ -456,7 +456,7 @@ class Procedure < ApplicationRecord
def percentile_time(start_attribute, end_attribute, p)
times = dossiers
.state_termine
.where(end_attribute => 1.month.ago..DateTime.current)
.where(end_attribute => 1.month.ago..Time.zone.now)
.pluck(start_attribute, end_attribute)
.map { |(start_date, end_date)| end_date - start_date }

View file

@ -60,7 +60,7 @@ class ProgressReport
def format_duration(seconds)
if seconds.finite?
Time.at(seconds).utc.strftime('%H:%M:%S')
Time.zone.at(seconds).strftime('%H:%M:%S')
else
'--:--:--'
end

View file

@ -1,6 +1,6 @@
class AdministrateurMailerPreview < ActionMailer::Preview
def activate_before_expiration
administrateur = Administrateur.new(reset_password_sent_at: Time.now.utc)
administrateur = Administrateur.new(reset_password_sent_at: Time.zone.now)
AdministrateurMailer.activate_before_expiration(administrateur, "a4d4e4f4b4d445")
end