DateTime.now => Time.zone.now

This commit is contained in:
simon lehericey 2018-10-25 15:07:15 +02:00
parent 4f1cc8a2f0
commit 13ffa61435
26 changed files with 39 additions and 39 deletions

View file

@ -43,7 +43,7 @@ class Admin::AttestationTemplatesController < AdminController
@title = activated_attestation_params[:title]
@body = activated_attestation_params[:body]
@footer = activated_attestation_params[:footer]
@created_at = DateTime.now
@created_at = Time.zone.now
# In a case of a preview, when the user does not change its images,
# the images are not uploaded and thus should be retrieved from previous

View file

@ -52,7 +52,7 @@ class Admin::GestionnairesController < AdminController
if User.exists?(email: @gestionnaire.email)
GestionnaireMailer.user_to_gestionnaire(@gestionnaire.email).deliver_later
else
User.create(email: email, password: password, confirmed_at: DateTime.now)
User.create(email: email, password: password, confirmed_at: Time.zone.now)
end
flash.notice = 'Instructeur ajouté'
else

View file

@ -15,7 +15,7 @@ class FranceConnect::ParticulierController < ApplicationController
if fci.user.nil?
user = User.find_or_create_by(email: fci.email_france_connect) do |new_user|
new_user.password = Devise.friendly_token[0, 20]
new_user.confirmed_at = DateTime.now
new_user.confirmed_at = Time.zone.now
end
fci.update_attribute('user_id', user.id)

View file

@ -89,7 +89,7 @@ module NewGestionnaire
if gestionnaire.save
user = User.find_by(email: email)
if user.blank?
user = User.create(email: email, password: password, confirmed_at: DateTime.now)
user = User.create(email: email, password: password, confirmed_at: Time.zone.now)
end
sign_in(user)

View file

@ -7,14 +7,14 @@ class AutoReceiveDossiersForProcedureJob < ApplicationJob
when Dossier.states.fetch(:en_instruction)
procedure.dossiers.state_en_construction.update_all(
state: Dossier.states.fetch(:en_instruction),
en_instruction_at: DateTime.now
en_instruction_at: Time.zone.now
)
when Dossier.states.fetch(:accepte)
procedure.dossiers.state_en_construction.find_each do |dossier|
dossier.update(
state: Dossier.states.fetch(:accepte),
en_instruction_at: DateTime.now,
processed_at: DateTime.now
en_instruction_at: Time.zone.now,
processed_at: Time.zone.now
)
dossier.attestation = dossier.build_attestation
dossier.save

View file

@ -22,7 +22,7 @@ class Administration < ApplicationRecord
User.create({
email: email,
password: password,
confirmed_at: DateTime.now
confirmed_at: Time.zone.now
})
end

View file

@ -180,7 +180,7 @@ class Dossier < ApplicationRecord
end
def retention_expired?
instruction_commencee? && retention_end_date <= DateTime.now
instruction_commencee? && retention_end_date <= Time.zone.now
end
def text_summary
@ -309,11 +309,11 @@ class Dossier < ApplicationRecord
def update_state_dates
if en_construction? && !self.en_construction_at
self.en_construction_at = DateTime.now
self.en_construction_at = Time.zone.now
elsif en_instruction? && !self.en_instruction_at
self.en_instruction_at = DateTime.now
self.en_instruction_at = Time.zone.now
elsif TERMINE.include?(state)
self.processed_at = DateTime.now
self.processed_at = Time.zone.now
end
end

View file

@ -9,9 +9,9 @@ class Follow < ApplicationRecord
private
def set_default_date
self.demande_seen_at ||= DateTime.now
self.annotations_privees_seen_at ||= DateTime.now
self.avis_seen_at ||= DateTime.now
self.messagerie_seen_at ||= DateTime.now
self.demande_seen_at ||= Time.zone.now
self.annotations_privees_seen_at ||= Time.zone.now
self.avis_seen_at ||= Time.zone.now
self.messagerie_seen_at ||= Time.zone.now
end
end

View file

@ -64,7 +64,7 @@ class Gestionnaire < ApplicationRecord
end
def last_week_overview
start_date = DateTime.now.beginning_of_week
start_date = Time.zone.now.beginning_of_week
active_procedure_overviews = procedures
.publiees
@ -180,7 +180,7 @@ class Gestionnaire < ApplicationRecord
def mark_tab_as_seen(dossier, tab)
attributes = {}
attributes["#{tab}_seen_at"] = DateTime.now
attributes["#{tab}_seen_at"] = Time.zone.now
Follow.where(gestionnaire: self, dossier: dossier).update_all(attributes)
end

View file

@ -305,7 +305,7 @@ class Procedure < ApplicationRecord
end
def whitelist!
update_attribute('whitelisted_at', DateTime.now)
update_attribute('whitelisted_at', Time.zone.now)
end
def closed_mail_template_attestation_inconsistency_state

View file

@ -24,7 +24,7 @@ class ProcedureOverview
@created_dossiers_count = procedure
.dossiers
.where(created_at: start_date..DateTime.now)
.where(created_at: start_date..Time.zone.now)
.state_not_brouillon
.count
end

View file

@ -1,4 +1,4 @@
- parsed_value = champ.value.present? ? DateTime.parse(champ.value) : DateTime.now
- parsed_value = champ.value.present? ? DateTime.parse(champ.value) : Time.zone.now
.datetime
= form.datetime_select(:value, selected: parsed_value, start_year: 1950, end_year: 2100, minute_step: 5)

View file

@ -7,7 +7,7 @@ class AddConfirmableToUserDevise < ActiveRecord::Migration[5.2]
# User.reset_column_information # Need for some types of updates, but not for update_all.
# To avoid a short time window between running the migration and updating all existing
# users as confirmed, do the following
User.all.update_all confirmed_at: DateTime.now
User.all.update_all confirmed_at: Time.zone.now
# All existing user accounts should be able to log in after this.
end

View file

@ -12,4 +12,4 @@ puts "Create test user '#{default_user}'"
Administration.create!(email: default_user, password: default_password)
Administrateur.create!(email: default_user, password: default_password)
Gestionnaire.create!(email: default_user, password: default_password)
User.create!(email: default_user, password: default_password, confirmed_at: DateTime.now)
User.create!(email: default_user, password: default_password, confirmed_at: Time.zone.now)

View file

@ -15,7 +15,7 @@ namespace :'2017_12_05_initialize_timestamps_for_entreprises' do
entreprise.update_columns(created_at: entreprise.dossier.created_at, updated_at: entreprise.dossier.created_at)
else
rake_puts "dossier #{entreprise.dossier_id} is missing for entreprise #{entreprise.id}"
entreprise.update_columns(created_at: DateTime.now, updated_at: DateTime.now)
entreprise.update_columns(created_at: Time.zone.now, updated_at: Time.zone.now)
end
end
end

View file

@ -24,7 +24,7 @@ namespace :'2018_06_06_users_for_admins_and_gestionnaires' do
User
.joins("INNER JOIN #{table_name} ON #{table_name}.email = users.email")
.where(confirmed_at: nil)
.update_all(confirmed_at: DateTime.now)
.update_all(confirmed_at: Time.zone.now)
rake_puts "Fixed #{count} #{table_name} with unconfirmed user"
end

View file

@ -47,7 +47,7 @@ describe Admin::AttestationTemplatesController, type: :controller do
it { expect(subject.status).to eq(200) }
it { expect(assigns).to include(upload_params.stringify_keys) }
it { expect(assigns[:created_at]).to eq(DateTime.now) }
it { expect(assigns[:created_at]).to eq(Time.zone.now) }
it { expect(assigns(:logo).read).to eq(logo.read) }
it { expect(assigns(:signature).read).to eq(signature.read) }
after { procedure.attestation_template.destroy }

View file

@ -250,11 +250,11 @@ describe NewGestionnaire::DossiersController, type: :controller do
end
before do
Timecop.freeze(DateTime.now)
Timecop.freeze(Time.zone.now)
expect_any_instance_of(AttestationTemplate)
.to receive(:attestation_for)
.with(have_attributes(motivation: "Yallah", processed_at: DateTime.now))
.with(have_attributes(motivation: "Yallah", processed_at: Time.zone.now))
end
after { Timecop.return }

View file

@ -57,7 +57,7 @@ describe Users::RegistrationsController, type: :controller do
end
context 'and the user is confirmed' do
let(:confirmed_at) { DateTime.now }
let(:confirmed_at) { Time.zone.now }
before { subject }

View file

@ -2,7 +2,7 @@ FactoryBot.define do
factory :deleted_dossier do
dossier_id { 1111 }
state { Dossier.states.fetch(:en_construction) }
deleted_at { DateTime.now }
deleted_at { Time.zone.now }
association :procedure, :published
end

View file

@ -155,7 +155,7 @@ FactoryBot.define do
trait :whitelisted do
after(:build) do |procedure, _evaluator|
procedure.update(whitelisted_at: DateTime.now)
procedure.update(whitelisted_at: Time.zone.now)
end
end

View file

@ -3,6 +3,6 @@ FactoryBot.define do
factory :user do
email { generate(:user_email) }
password { 'password' }
confirmed_at { DateTime.now }
confirmed_at { Time.zone.now }
end
end

View file

@ -2,7 +2,7 @@ require 'rails_helper'
RSpec.describe DossierHelper, type: :helper do
describe ".highlight_if_unseen_class" do
let(:seen_at) { DateTime.now }
let(:seen_at) { Time.zone.now }
subject { highlight_if_unseen_class(seen_at, updated_at) }
@ -19,7 +19,7 @@ RSpec.describe DossierHelper, type: :helper do
end
context "when there is no last seen datetime" do
let(:updated_at) { DateTime.now }
let(:updated_at) { Time.zone.now }
let(:seen_at) { nil }
it { is_expected.to eq nil }

View file

@ -25,7 +25,7 @@ RSpec.describe GestionnaireMailer, type: :mailer do
dossiers_en_instruction_description: 'desc')
{
start_date: DateTime.now,
start_date: Time.zone.now,
procedure_overviews: [procedure_overview]
}
end

View file

@ -982,7 +982,7 @@ describe Dossier do
context "retention date" do
let(:procedure) { create(:procedure, duree_conservation_dossiers_dans_ds: 6) }
let(:uninstructed_dossier) { create(:dossier, :en_construction, procedure: procedure) }
let(:young_dossier) { create(:dossier, :en_instruction, en_instruction_at: DateTime.now, procedure: procedure) }
let(:young_dossier) { create(:dossier, :en_instruction, en_instruction_at: Time.zone.now, procedure: procedure) }
let(:just_expired_dossier) { create(:dossier, :en_instruction, en_instruction_at: 6.months.ago, procedure: procedure) }
let(:long_expired_dossier) { create(:dossier, :en_instruction, en_instruction_at: 1.year.ago, procedure: procedure) }
let(:modif_date) { DateTime.parse('01/01/2100') }
@ -993,7 +993,7 @@ describe Dossier do
describe "#retention_end_date" do
it { expect(uninstructed_dossier.retention_end_date).to be_nil }
it { expect(young_dossier.retention_end_date).to eq(6.months.from_now) }
it { expect(just_expired_dossier.retention_end_date).to eq(DateTime.now) }
it { expect(just_expired_dossier.retention_end_date).to eq(Time.zone.now) }
it { expect(long_expired_dossier.retention_end_date).to eq(6.months.ago) }
end

View file

@ -139,7 +139,7 @@ describe Gestionnaire, type: :model do
let!(:gestionnaire2) { create(:gestionnaire) }
subject { gestionnaire2.last_week_overview }
let(:friday) { DateTime.new(2017, 5, 12) }
let(:monday) { DateTime.now.beginning_of_week }
let(:monday) { Time.zone.now.beginning_of_week }
before { Timecop.freeze(friday) }
after { Timecop.return }
@ -313,7 +313,7 @@ describe Gestionnaire, type: :model do
context 'when gestionnaire update it s public champs last seen' do
let(:follow) { gestionnaire.follows.find_by(dossier: dossier) }
before { follow.update_attribute('demande_seen_at', DateTime.now) }
before { follow.update_attribute('demande_seen_at', Time.zone.now) }
it { is_expected.to match([]) }
it { expect(gestionnaire_2.notifications_for_procedure(procedure)).to match([dossier.id]) }