From dd27167c5da10aa77aa2aefcfbb847b7f2cc10bf Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Mon, 18 Feb 2019 11:56:09 +0100 Subject: [PATCH 1/4] Enforce Timezone rule in Rubocop --- .rubocop.yml | 2 +- app/controllers/users/confirmations_controller.rb | 2 +- app/models/deleted_dossier.rb | 2 +- app/models/procedure.rb | 2 +- lib/tasks/task_helper.rb | 2 +- spec/mailers/previews/administrateur_mailer_preview.rb | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index afb11910f..307bc088d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -777,7 +777,7 @@ Rails/SkipsModelValidations: Enabled: false Rails/TimeZone: - Enabled: true + EnforcedStyle: strict Rails/UniqBeforePluck: Enabled: true diff --git a/app/controllers/users/confirmations_controller.rb b/app/controllers/users/confirmations_controller.rb index a93ac5600..ec5755987 100644 --- a/app/controllers/users/confirmations_controller.rb +++ b/app/controllers/users/confirmations_controller.rb @@ -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. diff --git a/app/models/deleted_dossier.rb b/app/models/deleted_dossier.rb index 9fba98749..25338f6b4 100644 --- a/app/models/deleted_dossier.rb +++ b/app/models/deleted_dossier.rb @@ -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 diff --git a/app/models/procedure.rb b/app/models/procedure.rb index c48b3ff37..992f273db 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -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 } diff --git a/lib/tasks/task_helper.rb b/lib/tasks/task_helper.rb index 7443af5ff..8be2ab6dc 100644 --- a/lib/tasks/task_helper.rb +++ b/lib/tasks/task_helper.rb @@ -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 diff --git a/spec/mailers/previews/administrateur_mailer_preview.rb b/spec/mailers/previews/administrateur_mailer_preview.rb index afa8762a0..18730819c 100644 --- a/spec/mailers/previews/administrateur_mailer_preview.rb +++ b/spec/mailers/previews/administrateur_mailer_preview.rb @@ -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 From 8ae468e8c77cacec1377ada08522f9ef4e394b57 Mon Sep 17 00:00:00 2001 From: clemkeirua Date: Mon, 18 Feb 2019 17:59:09 +0100 Subject: [PATCH 2/4] ajout de la date de depot pour l'instructeur --- app/views/shared/dossiers/_demande.html.haml | 4 ++++ app/views/shared/dossiers/_horodatage.html.haml | 5 +++++ 2 files changed, 9 insertions(+) create mode 100644 app/views/shared/dossiers/_horodatage.html.haml diff --git a/app/views/shared/dossiers/_demande.html.haml b/app/views/shared/dossiers/_demande.html.haml index 3d9ba3de8..1ac304855 100644 --- a/app/views/shared/dossiers/_demande.html.haml +++ b/app/views/shared/dossiers/_demande.html.haml @@ -1,4 +1,8 @@ .container + - if dossier.en_construction_at.present? + .card + = render partial: "shared/dossiers/horodatage", locals: { dossier: dossier } + .tab-title Identité du demandeur .card = render partial: "shared/dossiers/user_infos", locals: { user: dossier.user } diff --git a/app/views/shared/dossiers/_horodatage.html.haml b/app/views/shared/dossiers/_horodatage.html.haml new file mode 100644 index 000000000..c97b9c601 --- /dev/null +++ b/app/views/shared/dossiers/_horodatage.html.haml @@ -0,0 +1,5 @@ +%table.table.vertical.dossier-champs + %tbody + %tr + %th.libelle Déposé le : + %td= l(dossier.en_construction_at, format: '%d %B %Y') From 4ff9adde27eaddaa62ccfc335032a9edb2817fc2 Mon Sep 17 00:00:00 2001 From: clemkeirua Date: Tue, 19 Feb 2019 11:41:20 +0100 Subject: [PATCH 3/4] =?UTF-8?q?ajout=20d'un=20test=20auto=20pour=20l'affic?= =?UTF-8?q?hage=20de=20la=20date=20de=20d=C3=A9pot=20cot=C3=A9=20instructe?= =?UTF-8?q?ur?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/views/new_user/dossiers/demande.html.haml_spec.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spec/views/new_user/dossiers/demande.html.haml_spec.rb b/spec/views/new_user/dossiers/demande.html.haml_spec.rb index 074c55d78..869128d92 100644 --- a/spec/views/new_user/dossiers/demande.html.haml_spec.rb +++ b/spec/views/new_user/dossiers/demande.html.haml_spec.rb @@ -16,6 +16,7 @@ describe 'new_user/dossiers/demande.html.haml', type: :view do end it 'renders the dossier infos' do + expect(rendered).to have_text('Déposé le') expect(rendered).to have_text('Identité') expect(rendered).to have_text('Demande') expect(rendered).to have_text('Pièces jointes') @@ -29,4 +30,10 @@ describe 'new_user/dossiers/demande.html.haml', type: :view do let(:dossier) { create(:dossier, :en_instruction, :with_entreprise, procedure: procedure) } it { is_expected.not_to have_link('Modifier le dossier') } end + + context 'when the dossier has no en_construction_at date' do + let(:dossier) { create(:dossier, :with_entreprise, procedure: procedure) } + + it { expect(rendered).not_to have_text('Déposé le') } + end end From 540201cef5a98c03ceedec18cbab7cf7e3c4481c Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 19 Feb 2019 12:40:19 +0100 Subject: [PATCH 4/4] Fix sentry 230 --- app/controllers/administrateurs/activate_controller.rb | 2 +- app/controllers/gestionnaires/activate_controller.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/administrateurs/activate_controller.rb b/app/controllers/administrateurs/activate_controller.rb index dc2347e8b..96b441263 100644 --- a/app/controllers/administrateurs/activate_controller.rb +++ b/app/controllers/administrateurs/activate_controller.rb @@ -8,7 +8,7 @@ class Administrateurs::ActivateController < ApplicationController if @administrateur # the administrateur activates its account from an email - trust_device + trust_device(Time.zone.now) else flash.alert = "Le lien de validation d'administrateur a expiré, #{helpers.contact_link('contactez-nous', tags: 'lien expiré')} pour obtenir un nouveau lien." redirect_to root_path diff --git a/app/controllers/gestionnaires/activate_controller.rb b/app/controllers/gestionnaires/activate_controller.rb index 02a855bb2..e9c141ad6 100644 --- a/app/controllers/gestionnaires/activate_controller.rb +++ b/app/controllers/gestionnaires/activate_controller.rb @@ -6,7 +6,7 @@ class Gestionnaires::ActivateController < ApplicationController if @gestionnaire # the gestionnaire activates its account from an email - trust_device + trust_device(Time.zone.now) else flash.alert = "Le lien de validation du compte instructeur a expiré, #{helpers.contact_link('contactez-nous', tags: 'lien expiré')} pour obtenir un nouveau lien." redirect_to root_path