From 8ca683c515ab4995610798b22d26934259ae7c40 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Thu, 4 Apr 2019 10:41:44 +0200 Subject: [PATCH 1/6] mailers: fix last_week_overview crash when the overview is missing This is because procedures may be unpublished between the time where the job is enqueued and the time the mailer is run Fix #3745 --- app/mailers/gestionnaire_mailer.rb | 8 +++++--- spec/mailers/gestionnaire_mailer_spec.rb | 10 ++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/mailers/gestionnaire_mailer.rb b/app/mailers/gestionnaire_mailer.rb index 472f09dae..7607e37ac 100644 --- a/app/mailers/gestionnaire_mailer.rb +++ b/app/mailers/gestionnaire_mailer.rb @@ -21,11 +21,13 @@ class GestionnaireMailer < ApplicationMailer def last_week_overview(gestionnaire) email = gestionnaire.email - @overview = gestionnaire.last_week_overview - headers['X-mailjet-campaign'] = 'last_week_overview' @subject = 'Votre activité hebdomadaire' + @overview = gestionnaire.last_week_overview - mail(to: email, subject: @subject) + if @overview.present? + headers['X-mailjet-campaign'] = 'last_week_overview' + mail(to: email, subject: @subject) + end end def send_dossier(sender, dossier, recipient) diff --git a/spec/mailers/gestionnaire_mailer_spec.rb b/spec/mailers/gestionnaire_mailer_spec.rb index 40f4ea2a4..20e3c670c 100644 --- a/spec/mailers/gestionnaire_mailer_spec.rb +++ b/spec/mailers/gestionnaire_mailer_spec.rb @@ -35,5 +35,15 @@ RSpec.describe GestionnaireMailer, type: :mailer do subject { described_class.last_week_overview(gestionnaire) } it { expect(subject.body).to include('Votre activité hebdomadaire') } + + context 'when the gestionnaire has no active procedures' do + let(:procedure) { nil } + let(:last_week_overview) { nil } + + it 'doesn’t send the email' do + expect(subject.message).to be_kind_of(ActionMailer::Base::NullMail) + expect(subject.body).to be_blank + end + end end end From e34c556f296480c0937c1e6933a8a7683c3c68fc Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 8 Apr 2019 15:24:44 +0200 Subject: [PATCH 2/6] procedure: fix specs When the time computations are done accross a Daylight Saving Time change, they may be off by one hour. It doesn't matter, as the estimated delay is counted in days, not hours. --- spec/models/procedure_spec.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/models/procedure_spec.rb b/spec/models/procedure_spec.rb index 1a26b4704..7337b1cf5 100644 --- a/spec/models/procedure_spec.rb +++ b/spec/models/procedure_spec.rb @@ -754,13 +754,13 @@ describe Procedure do let!(:old_dossier) { create_dossier(construction_date: 3.months.ago, instruction_date: 2.months.ago) } it 'ignores dossiers older than 1 month' do - expect(procedure.usual_verification_time).to be_within(10.seconds).of(2.days) + expect(procedure.usual_verification_time).to be_within(1.hour).of(2.days) end end context 'when there is only one dossier in the time frame' do let(:delays) { [1.day] } - it { expect(procedure.usual_verification_time).to be_within(10.seconds).of(1.day) } + it { expect(procedure.usual_verification_time).to be_within(1.hour).of(1.day) } end context 'where there are no dossiers' do @@ -796,7 +796,7 @@ describe Procedure do let!(:old_dossier) { create_dossier(instruction_date: 3.months.ago, processed_date: 2.months.ago) } it 'ignores dossiers older than 1 month' do - expect(procedure.usual_instruction_time).to be_within(10.seconds).of(2.days) + expect(procedure.usual_instruction_time).to be_within(1.hour).of(2.days) end end @@ -805,13 +805,13 @@ describe Procedure do let!(:bad_dossier) { create_dossier(instruction_date: nil, processed_date: 10.days.ago) } it 'ignores bad dossiers' do - expect(procedure.usual_instruction_time).to be_within(10.seconds).of(2.days) + expect(procedure.usual_instruction_time).to be_within(1.hour).of(2.days) end end context 'when there is only one processed dossier' do let(:delays) { [1.day] } - it { expect(procedure.usual_instruction_time).to be_within(10.seconds).of(1.day) } + it { expect(procedure.usual_instruction_time).to be_within(1.hour).of(1.day) } end context 'where there is no processed dossier' do From 65b0d7ab5e4846cfe41961f890c463c62551c3bc Mon Sep 17 00:00:00 2001 From: Nicolas Bouilleaud Date: Mon, 8 Apr 2019 15:27:10 +0200 Subject: [PATCH 3/6] Ignore Rubymine project files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 96f49c920..9a9dd9ca4 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ storage/ yarn-debug.log* .yarn-integrity /.vscode +/.idea /public/packs /public/packs-test /node_modules From da07f2abf8c821a08c88dedc9adc225ffd95b020 Mon Sep 17 00:00:00 2001 From: Nicolas Bouilleaud Date: Mon, 8 Apr 2019 15:27:36 +0200 Subject: [PATCH 4/6] Fix chromedriver install command in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 39f802e98..ed501dad8 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ Vous souhaitez y apporter des changements ou des améliorations ? Lisez notre [ - Chrome - chromedriver : - * Mac : `brew install chromedriver` + * Mac : `brew cask install chromedriver` * Linux : voir https://sites.google.com/a/chromium.org/chromedriver/downloads ### Création des rôles de la base de données From c1d1754236bef32f00e7bb2dde55057d80bbc590 Mon Sep 17 00:00:00 2001 From: Nicolas Bouilleaud Date: Mon, 8 Apr 2019 15:31:36 +0200 Subject: [PATCH 5/6] Fix a typo in admin/procedures --- app/views/admin/procedures/show.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admin/procedures/show.html.haml b/app/views/admin/procedures/show.html.haml index 65828af5b..84a5a260e 100644 --- a/app/views/admin/procedures/show.html.haml +++ b/app/views/admin/procedures/show.html.haml @@ -65,7 +65,7 @@ pour y accéder vous pouvez utiliser le lien : = link_to procedure_lien(@procedure), sanitize_url(procedure_lien(@procedure)), target: :blank, rel: :noopener %p - Tout personne ayant la connaissance de ce lien pourra ainsi remplir des dossiers de test sur votre démarche. + Toute personne ayant la connaissance de ce lien pourra ainsi remplir des dossiers de test sur votre démarche. %br %h4 Ce que vous pouvez faire lorsque vous êtes en test From 052bd9a9fc28bcb6cc3ba4693ef5d03b210217bc Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 4 Apr 2019 17:35:49 +0200 Subject: [PATCH 6/6] [Fix #3682] Remove placeholder on textarea champ --- app/views/shared/dossiers/editable_champs/_textarea.html.haml | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/shared/dossiers/editable_champs/_textarea.html.haml b/app/views/shared/dossiers/editable_champs/_textarea.html.haml index c1bac654c..620f11c6d 100644 --- a/app/views/shared/dossiers/editable_champs/_textarea.html.haml +++ b/app/views/shared/dossiers/editable_champs/_textarea.html.haml @@ -1,5 +1,4 @@ ~ form.text_area :value, row: 6, - placeholder: champ.description, required: champ.mandatory?, value: html_to_string(champ.value)