DateTime.now => Time.zone.now
This commit is contained in:
parent
4f1cc8a2f0
commit
13ffa61435
26 changed files with 39 additions and 39 deletions
|
@ -43,7 +43,7 @@ class Admin::AttestationTemplatesController < AdminController
|
||||||
@title = activated_attestation_params[:title]
|
@title = activated_attestation_params[:title]
|
||||||
@body = activated_attestation_params[:body]
|
@body = activated_attestation_params[:body]
|
||||||
@footer = activated_attestation_params[:footer]
|
@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,
|
# 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
|
# the images are not uploaded and thus should be retrieved from previous
|
||||||
|
|
|
@ -52,7 +52,7 @@ class Admin::GestionnairesController < AdminController
|
||||||
if User.exists?(email: @gestionnaire.email)
|
if User.exists?(email: @gestionnaire.email)
|
||||||
GestionnaireMailer.user_to_gestionnaire(@gestionnaire.email).deliver_later
|
GestionnaireMailer.user_to_gestionnaire(@gestionnaire.email).deliver_later
|
||||||
else
|
else
|
||||||
User.create(email: email, password: password, confirmed_at: DateTime.now)
|
User.create(email: email, password: password, confirmed_at: Time.zone.now)
|
||||||
end
|
end
|
||||||
flash.notice = 'Instructeur ajouté'
|
flash.notice = 'Instructeur ajouté'
|
||||||
else
|
else
|
||||||
|
|
|
@ -15,7 +15,7 @@ class FranceConnect::ParticulierController < ApplicationController
|
||||||
if fci.user.nil?
|
if fci.user.nil?
|
||||||
user = User.find_or_create_by(email: fci.email_france_connect) do |new_user|
|
user = User.find_or_create_by(email: fci.email_france_connect) do |new_user|
|
||||||
new_user.password = Devise.friendly_token[0, 20]
|
new_user.password = Devise.friendly_token[0, 20]
|
||||||
new_user.confirmed_at = DateTime.now
|
new_user.confirmed_at = Time.zone.now
|
||||||
end
|
end
|
||||||
|
|
||||||
fci.update_attribute('user_id', user.id)
|
fci.update_attribute('user_id', user.id)
|
||||||
|
|
|
@ -89,7 +89,7 @@ module NewGestionnaire
|
||||||
if gestionnaire.save
|
if gestionnaire.save
|
||||||
user = User.find_by(email: email)
|
user = User.find_by(email: email)
|
||||||
if user.blank?
|
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
|
end
|
||||||
|
|
||||||
sign_in(user)
|
sign_in(user)
|
||||||
|
|
|
@ -7,14 +7,14 @@ class AutoReceiveDossiersForProcedureJob < ApplicationJob
|
||||||
when Dossier.states.fetch(:en_instruction)
|
when Dossier.states.fetch(:en_instruction)
|
||||||
procedure.dossiers.state_en_construction.update_all(
|
procedure.dossiers.state_en_construction.update_all(
|
||||||
state: Dossier.states.fetch(:en_instruction),
|
state: Dossier.states.fetch(:en_instruction),
|
||||||
en_instruction_at: DateTime.now
|
en_instruction_at: Time.zone.now
|
||||||
)
|
)
|
||||||
when Dossier.states.fetch(:accepte)
|
when Dossier.states.fetch(:accepte)
|
||||||
procedure.dossiers.state_en_construction.find_each do |dossier|
|
procedure.dossiers.state_en_construction.find_each do |dossier|
|
||||||
dossier.update(
|
dossier.update(
|
||||||
state: Dossier.states.fetch(:accepte),
|
state: Dossier.states.fetch(:accepte),
|
||||||
en_instruction_at: DateTime.now,
|
en_instruction_at: Time.zone.now,
|
||||||
processed_at: DateTime.now
|
processed_at: Time.zone.now
|
||||||
)
|
)
|
||||||
dossier.attestation = dossier.build_attestation
|
dossier.attestation = dossier.build_attestation
|
||||||
dossier.save
|
dossier.save
|
||||||
|
|
|
@ -22,7 +22,7 @@ class Administration < ApplicationRecord
|
||||||
User.create({
|
User.create({
|
||||||
email: email,
|
email: email,
|
||||||
password: password,
|
password: password,
|
||||||
confirmed_at: DateTime.now
|
confirmed_at: Time.zone.now
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -180,7 +180,7 @@ class Dossier < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def retention_expired?
|
def retention_expired?
|
||||||
instruction_commencee? && retention_end_date <= DateTime.now
|
instruction_commencee? && retention_end_date <= Time.zone.now
|
||||||
end
|
end
|
||||||
|
|
||||||
def text_summary
|
def text_summary
|
||||||
|
@ -309,11 +309,11 @@ class Dossier < ApplicationRecord
|
||||||
|
|
||||||
def update_state_dates
|
def update_state_dates
|
||||||
if en_construction? && !self.en_construction_at
|
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
|
elsif en_instruction? && !self.en_instruction_at
|
||||||
self.en_instruction_at = DateTime.now
|
self.en_instruction_at = Time.zone.now
|
||||||
elsif TERMINE.include?(state)
|
elsif TERMINE.include?(state)
|
||||||
self.processed_at = DateTime.now
|
self.processed_at = Time.zone.now
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,9 @@ class Follow < ApplicationRecord
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_default_date
|
def set_default_date
|
||||||
self.demande_seen_at ||= DateTime.now
|
self.demande_seen_at ||= Time.zone.now
|
||||||
self.annotations_privees_seen_at ||= DateTime.now
|
self.annotations_privees_seen_at ||= Time.zone.now
|
||||||
self.avis_seen_at ||= DateTime.now
|
self.avis_seen_at ||= Time.zone.now
|
||||||
self.messagerie_seen_at ||= DateTime.now
|
self.messagerie_seen_at ||= Time.zone.now
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -64,7 +64,7 @@ class Gestionnaire < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def last_week_overview
|
def last_week_overview
|
||||||
start_date = DateTime.now.beginning_of_week
|
start_date = Time.zone.now.beginning_of_week
|
||||||
|
|
||||||
active_procedure_overviews = procedures
|
active_procedure_overviews = procedures
|
||||||
.publiees
|
.publiees
|
||||||
|
@ -180,7 +180,7 @@ class Gestionnaire < ApplicationRecord
|
||||||
|
|
||||||
def mark_tab_as_seen(dossier, tab)
|
def mark_tab_as_seen(dossier, tab)
|
||||||
attributes = {}
|
attributes = {}
|
||||||
attributes["#{tab}_seen_at"] = DateTime.now
|
attributes["#{tab}_seen_at"] = Time.zone.now
|
||||||
Follow.where(gestionnaire: self, dossier: dossier).update_all(attributes)
|
Follow.where(gestionnaire: self, dossier: dossier).update_all(attributes)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -305,7 +305,7 @@ class Procedure < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def whitelist!
|
def whitelist!
|
||||||
update_attribute('whitelisted_at', DateTime.now)
|
update_attribute('whitelisted_at', Time.zone.now)
|
||||||
end
|
end
|
||||||
|
|
||||||
def closed_mail_template_attestation_inconsistency_state
|
def closed_mail_template_attestation_inconsistency_state
|
||||||
|
|
|
@ -24,7 +24,7 @@ class ProcedureOverview
|
||||||
|
|
||||||
@created_dossiers_count = procedure
|
@created_dossiers_count = procedure
|
||||||
.dossiers
|
.dossiers
|
||||||
.where(created_at: start_date..DateTime.now)
|
.where(created_at: start_date..Time.zone.now)
|
||||||
.state_not_brouillon
|
.state_not_brouillon
|
||||||
.count
|
.count
|
||||||
end
|
end
|
||||||
|
|
|
@ -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
|
.datetime
|
||||||
= form.datetime_select(:value, selected: parsed_value, start_year: 1950, end_year: 2100, minute_step: 5)
|
= form.datetime_select(:value, selected: parsed_value, start_year: 1950, end_year: 2100, minute_step: 5)
|
||||||
|
|
|
@ -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.
|
# 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
|
# To avoid a short time window between running the migration and updating all existing
|
||||||
# users as confirmed, do the following
|
# 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.
|
# All existing user accounts should be able to log in after this.
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -12,4 +12,4 @@ puts "Create test user '#{default_user}'"
|
||||||
Administration.create!(email: default_user, password: default_password)
|
Administration.create!(email: default_user, password: default_password)
|
||||||
Administrateur.create!(email: default_user, password: default_password)
|
Administrateur.create!(email: default_user, password: default_password)
|
||||||
Gestionnaire.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)
|
||||||
|
|
|
@ -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)
|
entreprise.update_columns(created_at: entreprise.dossier.created_at, updated_at: entreprise.dossier.created_at)
|
||||||
else
|
else
|
||||||
rake_puts "dossier #{entreprise.dossier_id} is missing for entreprise #{entreprise.id}"
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace :'2018_06_06_users_for_admins_and_gestionnaires' do
|
||||||
User
|
User
|
||||||
.joins("INNER JOIN #{table_name} ON #{table_name}.email = users.email")
|
.joins("INNER JOIN #{table_name} ON #{table_name}.email = users.email")
|
||||||
.where(confirmed_at: nil)
|
.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"
|
rake_puts "Fixed #{count} #{table_name} with unconfirmed user"
|
||||||
end
|
end
|
||||||
|
|
|
@ -47,7 +47,7 @@ describe Admin::AttestationTemplatesController, type: :controller do
|
||||||
|
|
||||||
it { expect(subject.status).to eq(200) }
|
it { expect(subject.status).to eq(200) }
|
||||||
it { expect(assigns).to include(upload_params.stringify_keys) }
|
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(:logo).read).to eq(logo.read) }
|
||||||
it { expect(assigns(:signature).read).to eq(signature.read) }
|
it { expect(assigns(:signature).read).to eq(signature.read) }
|
||||||
after { procedure.attestation_template.destroy }
|
after { procedure.attestation_template.destroy }
|
||||||
|
|
|
@ -250,11 +250,11 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Timecop.freeze(DateTime.now)
|
Timecop.freeze(Time.zone.now)
|
||||||
|
|
||||||
expect_any_instance_of(AttestationTemplate)
|
expect_any_instance_of(AttestationTemplate)
|
||||||
.to receive(:attestation_for)
|
.to receive(:attestation_for)
|
||||||
.with(have_attributes(motivation: "Yallah", processed_at: DateTime.now))
|
.with(have_attributes(motivation: "Yallah", processed_at: Time.zone.now))
|
||||||
end
|
end
|
||||||
|
|
||||||
after { Timecop.return }
|
after { Timecop.return }
|
||||||
|
|
|
@ -57,7 +57,7 @@ describe Users::RegistrationsController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'and the user is confirmed' do
|
context 'and the user is confirmed' do
|
||||||
let(:confirmed_at) { DateTime.now }
|
let(:confirmed_at) { Time.zone.now }
|
||||||
|
|
||||||
before { subject }
|
before { subject }
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ FactoryBot.define do
|
||||||
factory :deleted_dossier do
|
factory :deleted_dossier do
|
||||||
dossier_id { 1111 }
|
dossier_id { 1111 }
|
||||||
state { Dossier.states.fetch(:en_construction) }
|
state { Dossier.states.fetch(:en_construction) }
|
||||||
deleted_at { DateTime.now }
|
deleted_at { Time.zone.now }
|
||||||
|
|
||||||
association :procedure, :published
|
association :procedure, :published
|
||||||
end
|
end
|
||||||
|
|
|
@ -155,7 +155,7 @@ FactoryBot.define do
|
||||||
|
|
||||||
trait :whitelisted do
|
trait :whitelisted do
|
||||||
after(:build) do |procedure, _evaluator|
|
after(:build) do |procedure, _evaluator|
|
||||||
procedure.update(whitelisted_at: DateTime.now)
|
procedure.update(whitelisted_at: Time.zone.now)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,6 @@ FactoryBot.define do
|
||||||
factory :user do
|
factory :user do
|
||||||
email { generate(:user_email) }
|
email { generate(:user_email) }
|
||||||
password { 'password' }
|
password { 'password' }
|
||||||
confirmed_at { DateTime.now }
|
confirmed_at { Time.zone.now }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,7 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe DossierHelper, type: :helper do
|
RSpec.describe DossierHelper, type: :helper do
|
||||||
describe ".highlight_if_unseen_class" 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) }
|
subject { highlight_if_unseen_class(seen_at, updated_at) }
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ RSpec.describe DossierHelper, type: :helper do
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when there is no last seen datetime" do
|
context "when there is no last seen datetime" do
|
||||||
let(:updated_at) { DateTime.now }
|
let(:updated_at) { Time.zone.now }
|
||||||
let(:seen_at) { nil }
|
let(:seen_at) { nil }
|
||||||
|
|
||||||
it { is_expected.to eq nil }
|
it { is_expected.to eq nil }
|
||||||
|
|
|
@ -25,7 +25,7 @@ RSpec.describe GestionnaireMailer, type: :mailer do
|
||||||
dossiers_en_instruction_description: 'desc')
|
dossiers_en_instruction_description: 'desc')
|
||||||
|
|
||||||
{
|
{
|
||||||
start_date: DateTime.now,
|
start_date: Time.zone.now,
|
||||||
procedure_overviews: [procedure_overview]
|
procedure_overviews: [procedure_overview]
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -982,7 +982,7 @@ describe Dossier do
|
||||||
context "retention date" do
|
context "retention date" do
|
||||||
let(:procedure) { create(:procedure, duree_conservation_dossiers_dans_ds: 6) }
|
let(:procedure) { create(:procedure, duree_conservation_dossiers_dans_ds: 6) }
|
||||||
let(:uninstructed_dossier) { create(:dossier, :en_construction, procedure: procedure) }
|
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(: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(:long_expired_dossier) { create(:dossier, :en_instruction, en_instruction_at: 1.year.ago, procedure: procedure) }
|
||||||
let(:modif_date) { DateTime.parse('01/01/2100') }
|
let(:modif_date) { DateTime.parse('01/01/2100') }
|
||||||
|
@ -993,7 +993,7 @@ describe Dossier do
|
||||||
describe "#retention_end_date" do
|
describe "#retention_end_date" do
|
||||||
it { expect(uninstructed_dossier.retention_end_date).to be_nil }
|
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(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) }
|
it { expect(long_expired_dossier.retention_end_date).to eq(6.months.ago) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,7 @@ describe Gestionnaire, type: :model do
|
||||||
let!(:gestionnaire2) { create(:gestionnaire) }
|
let!(:gestionnaire2) { create(:gestionnaire) }
|
||||||
subject { gestionnaire2.last_week_overview }
|
subject { gestionnaire2.last_week_overview }
|
||||||
let(:friday) { DateTime.new(2017, 5, 12) }
|
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) }
|
before { Timecop.freeze(friday) }
|
||||||
after { Timecop.return }
|
after { Timecop.return }
|
||||||
|
@ -313,7 +313,7 @@ describe Gestionnaire, type: :model do
|
||||||
context 'when gestionnaire update it s public champs last seen' do
|
context 'when gestionnaire update it s public champs last seen' do
|
||||||
let(:follow) { gestionnaire.follows.find_by(dossier: dossier) }
|
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 { is_expected.to match([]) }
|
||||||
it { expect(gestionnaire_2.notifications_for_procedure(procedure)).to match([dossier.id]) }
|
it { expect(gestionnaire_2.notifications_for_procedure(procedure)).to match([dossier.id]) }
|
||||||
|
|
Loading…
Reference in a new issue