From e73086ee4ca37b635ebf3fd36d906dd3e58edf2d Mon Sep 17 00:00:00 2001 From: Judith Date: Wed, 20 May 2020 16:00:05 +0200 Subject: [PATCH 1/5] views: added the precision of the time zone for auto_archive fix #5181 --- .../dossier_mailer/notify_brouillon_not_submitted.html.haml | 2 +- app/views/new_administrateur/procedures/_informations.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/dossier_mailer/notify_brouillon_not_submitted.html.haml b/app/views/dossier_mailer/notify_brouillon_not_submitted.html.haml index fe4e33910..e53f6d685 100644 --- a/app/views/dossier_mailer/notify_brouillon_not_submitted.html.haml +++ b/app/views/dossier_mailer/notify_brouillon_not_submitted.html.haml @@ -10,7 +10,7 @@  » est commencé mais n'est pas encore déposé. %p Si vous souhaitez que ce dossier soit pris en compte, il vous faut le déposer avant le - #{l(@dossier.procedure.auto_archive_on - 1.day, format: '%-d %B %Y')} à 23h59, date de cloture de la démarche. + #{l(@dossier.procedure.auto_archive_on - 1.day, format: '%-d %B %Y')} à 23 h 59 (heure de #{Rails.application.config.time_zone}), date limite de dépôt des dossiers. %p Pour cela, affichez le dossier avec le bouton ci-dessous, vérifiez votre dossier puis cliquez sur le bouton diff --git a/app/views/new_administrateur/procedures/_informations.html.haml b/app/views/new_administrateur/procedures/_informations.html.haml index db14b75a1..ff90d71e3 100644 --- a/app/views/new_administrateur/procedures/_informations.html.haml +++ b/app/views/new_administrateur/procedures/_informations.html.haml @@ -115,7 +115,7 @@ Le - value = @procedure.auto_archive_on ? @procedure.auto_archive_on - 1.day : nil = f.date_field :auto_archive_on, id: 'auto_archive_on', value: value - à 23 h 59 + à 23 h 59 (heure de #{Rails.application.config.time_zone}). = f.label :declarative_with_state do Démarche déclarative From 59346ee868c0a25ff939358affe22ed618e7b19d Mon Sep 17 00:00:00 2001 From: Judith Date: Wed, 20 May 2020 16:50:48 +0200 Subject: [PATCH 2/5] mailers: mention the auto_archive in notify_new_draft --- app/views/dossier_mailer/notify_new_draft.html.haml | 4 ++++ spec/factories/procedure.rb | 4 ++++ spec/mailers/dossier_mailer_spec.rb | 3 ++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/views/dossier_mailer/notify_new_draft.html.haml b/app/views/dossier_mailer/notify_new_draft.html.haml index 93c8afcd1..c641d8d55 100644 --- a/app/views/dossier_mailer/notify_new_draft.html.haml +++ b/app/views/dossier_mailer/notify_new_draft.html.haml @@ -16,6 +16,10 @@ = round_button('Afficher votre dossier', dossier_url(@dossier), :primary) +- if @dossier.procedure.auto_archive_on + %p + Vous pouvez déposer votre dossier jusqu'au #{l(@dossier.procedure.auto_archive_on - 1.day, format: '%-d %B %Y')} à 23 h 59 (heure de #{Rails.application.config.time_zone}). + = render 'layouts/mailers/signature' - content_for :footer do diff --git a/spec/factories/procedure.rb b/spec/factories/procedure.rb index 5d74a59cf..7fcc26f39 100644 --- a/spec/factories/procedure.rb +++ b/spec/factories/procedure.rb @@ -86,6 +86,10 @@ FactoryBot.define do end end + trait :with_auto_archive do + auto_archive_on { Time.zone.today + 20 } + end + trait :with_type_de_champ do transient do types_de_champ_count { 1 } diff --git a/spec/mailers/dossier_mailer_spec.rb b/spec/mailers/dossier_mailer_spec.rb index b2d577feb..a956ef36b 100644 --- a/spec/mailers/dossier_mailer_spec.rb +++ b/spec/mailers/dossier_mailer_spec.rb @@ -12,7 +12,7 @@ RSpec.describe DossierMailer, type: :mailer do end describe '.notify_new_draft' do - let(:dossier) { create(:dossier, procedure: build(:simple_procedure)) } + let(:dossier) { create(:dossier, procedure: build(:simple_procedure, :with_auto_archive)) } subject { described_class.notify_new_draft(dossier) } @@ -20,6 +20,7 @@ RSpec.describe DossierMailer, type: :mailer do it { expect(subject.subject).to include(dossier.procedure.libelle) } it { expect(subject.body).to include(dossier.procedure.libelle) } it { expect(subject.body).to include(dossier_url(dossier)) } + it { expect(subject.body).to include("Vous pouvez déposer votre dossier jusqu'au") } it_behaves_like 'a dossier notification' end From 38eb60f2ac9c18e295536ea83fa405bbf28559c9 Mon Sep 17 00:00:00 2001 From: Judith Date: Wed, 27 May 2020 11:25:43 +0200 Subject: [PATCH 3/5] views: display auto-archive date on procedure description --- .../new_design/procedure_context.scss | 23 +++++++++++++++++ app/helpers/procedure_helper.rb | 4 +++ .../shared/_procedure_description.html.haml | 9 +++++++ spec/helpers/procedure_helper_spec.rb | 10 ++++++++ .../_procedure_description.html.haml_spec.rb | 25 +++++++++++++++++++ 5 files changed, 71 insertions(+) create mode 100644 spec/helpers/procedure_helper_spec.rb create mode 100644 spec/views/shared/_procedure_description.html.haml_spec.rb diff --git a/app/assets/stylesheets/new_design/procedure_context.scss b/app/assets/stylesheets/new_design/procedure_context.scss index 54df80fd2..7154cc30b 100644 --- a/app/assets/stylesheets/new_design/procedure_context.scss +++ b/app/assets/stylesheets/new_design/procedure_context.scss @@ -37,6 +37,29 @@ $procedure-description-line-height: 22px; } } + .procedure-auto-archive { + cursor: pointer; + + margin-bottom: 32px; + + p { + padding-top: 8px; + font-size: 16px; + } + + summary { + font-size: 20px; + + &:-webkit-details-marker { + display: none; + } + } + } + + .procedure-auto-archive-title { + border-bottom: 1px dotted $blue; + } + .procedure-description { font-size: 16px; diff --git a/app/helpers/procedure_helper.rb b/app/helpers/procedure_helper.rb index a6bb001de..17a757d93 100644 --- a/app/helpers/procedure_helper.rb +++ b/app/helpers/procedure_helper.rb @@ -38,5 +38,9 @@ module ProcedureHelper } end + def show_auto_archive(procedure) + I18n.l(procedure.auto_archive_on - 1.day, format: '%-d %B %Y') + end + private end diff --git a/app/views/shared/_procedure_description.html.haml b/app/views/shared/_procedure_description.html.haml index 7f8de4547..ba241bda0 100644 --- a/app/views/shared/_procedure_description.html.haml +++ b/app/views/shared/_procedure_description.html.haml @@ -7,6 +7,15 @@ = image_tag("flag_of_europe.svg", id: 'euro_flag', class: (!procedure.euro_flag ? "hidden" : "")) %h1.procedure-title = procedure.libelle + +- if procedure.auto_archive_on + %details.procedure-auto-archive + %summary + %span.icon.clock + + %span.procedure-auto-archive-title Date limite : #{show_auto_archive(procedure)} + %p Vous pouvez déposer vos dossiers jusqu'au #{show_auto_archive(procedure)} à 23 h 59 (heure de #{Rails.application.config.time_zone}). + .procedure-description .procedure-description-body.read-more-enabled.read-more-collapsed = h string_to_html(procedure.description) diff --git a/spec/helpers/procedure_helper_spec.rb b/spec/helpers/procedure_helper_spec.rb new file mode 100644 index 000000000..43476eeae --- /dev/null +++ b/spec/helpers/procedure_helper_spec.rb @@ -0,0 +1,10 @@ +RSpec.describe ProcedureHelper, type: :helper do + let(:auto_archive_date) { Time.zone.local(2020, 8, 2, 12, 00) } + let(:procedure) { create(:procedure, auto_archive_on: auto_archive_date) } + + subject { show_auto_archive(procedure) } + + it "displays the day before the auto archive date (to account for the '23h59' ending time)" do + expect(subject).to eq "1 août 2020" + end +end diff --git a/spec/views/shared/_procedure_description.html.haml_spec.rb b/spec/views/shared/_procedure_description.html.haml_spec.rb new file mode 100644 index 000000000..85005909b --- /dev/null +++ b/spec/views/shared/_procedure_description.html.haml_spec.rb @@ -0,0 +1,25 @@ +describe 'shared/_procedure_description.html.haml', type: :view do + let(:procedure) { create(:procedure, :published, :with_service) } + + subject { render partial: 'shared/procedure_description', locals: { procedure: procedure } } + + it 'renders the view' do + subject + expect(rendered).to have_selector('.procedure-logos') + expect(rendered).to have_text(procedure.libelle) + expect(rendered).to have_text(procedure.description) + end + + it 'does not show empty date limite' do + subject + expect(rendered).not_to have_text('Date limite') + end + + context 'when the procedure has an auto_archive date' do + let(:procedure) { create(:procedure, :published, :with_service, :with_auto_archive) } + it 'shows the auto_archive_on' do + subject + expect(rendered).to have_text('Date limite') + end + end +end From 6b65ee8d15eeef959291bf6e072d96befe55ab00 Mon Sep 17 00:00:00 2001 From: Judith Date: Wed, 27 May 2020 11:33:04 +0200 Subject: [PATCH 4/5] mailers: display auto-archive date in notifications --- app/mailers/dossier_mailer.rb | 1 + .../dossier_mailer/notify_brouillon_not_submitted.html.haml | 2 +- app/views/dossier_mailer/notify_new_draft.html.haml | 2 +- spec/mailers/dossier_mailer_spec.rb | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/mailers/dossier_mailer.rb b/app/mailers/dossier_mailer.rb index 36d4bd17d..c650c0a8f 100644 --- a/app/mailers/dossier_mailer.rb +++ b/app/mailers/dossier_mailer.rb @@ -2,6 +2,7 @@ class DossierMailer < ApplicationMailer helper ServiceHelper helper MailerHelper + helper ProcedureHelper layout 'mailers/layout' diff --git a/app/views/dossier_mailer/notify_brouillon_not_submitted.html.haml b/app/views/dossier_mailer/notify_brouillon_not_submitted.html.haml index e53f6d685..43c4b64f0 100644 --- a/app/views/dossier_mailer/notify_brouillon_not_submitted.html.haml +++ b/app/views/dossier_mailer/notify_brouillon_not_submitted.html.haml @@ -10,7 +10,7 @@  » est commencé mais n'est pas encore déposé. %p Si vous souhaitez que ce dossier soit pris en compte, il vous faut le déposer avant le - #{l(@dossier.procedure.auto_archive_on - 1.day, format: '%-d %B %Y')} à 23 h 59 (heure de #{Rails.application.config.time_zone}), date limite de dépôt des dossiers. + #{show_auto_archive(@dossier.procedure)} à 23 h 59 (heure de #{Rails.application.config.time_zone}), date limite de dépôt des dossiers. %p Pour cela, affichez le dossier avec le bouton ci-dessous, vérifiez votre dossier puis cliquez sur le bouton diff --git a/app/views/dossier_mailer/notify_new_draft.html.haml b/app/views/dossier_mailer/notify_new_draft.html.haml index c641d8d55..337c8c351 100644 --- a/app/views/dossier_mailer/notify_new_draft.html.haml +++ b/app/views/dossier_mailer/notify_new_draft.html.haml @@ -18,7 +18,7 @@ - if @dossier.procedure.auto_archive_on %p - Vous pouvez déposer votre dossier jusqu'au #{l(@dossier.procedure.auto_archive_on - 1.day, format: '%-d %B %Y')} à 23 h 59 (heure de #{Rails.application.config.time_zone}). + Vous pouvez déposer votre dossier jusqu'au #{show_auto_archive(@dossier.procedure)} à 23 h 59 (heure de #{Rails.application.config.time_zone}). = render 'layouts/mailers/signature' diff --git a/spec/mailers/dossier_mailer_spec.rb b/spec/mailers/dossier_mailer_spec.rb index a956ef36b..ad9e38ebe 100644 --- a/spec/mailers/dossier_mailer_spec.rb +++ b/spec/mailers/dossier_mailer_spec.rb @@ -21,6 +21,7 @@ RSpec.describe DossierMailer, type: :mailer do it { expect(subject.body).to include(dossier.procedure.libelle) } it { expect(subject.body).to include(dossier_url(dossier)) } it { expect(subject.body).to include("Vous pouvez déposer votre dossier jusqu'au") } + it { expect(subject.body).to include("heure de") } it_behaves_like 'a dossier notification' end From d9301248397e44c4a3d3e6ce3007684bd70ebf5b Mon Sep 17 00:00:00 2001 From: Judith Date: Wed, 27 May 2020 18:04:22 +0200 Subject: [PATCH 5/5] change procedure_auto_archive helper name and added a helper for 23 h 59 --- app/helpers/procedure_helper.rb | 10 ++++++++-- .../notify_brouillon_not_submitted.html.haml | 2 +- app/views/dossier_mailer/notify_new_draft.html.haml | 2 +- .../procedures/_informations.html.haml | 2 +- app/views/shared/_procedure_description.html.haml | 4 ++-- spec/helpers/procedure_helper_spec.rb | 6 +++--- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/app/helpers/procedure_helper.rb b/app/helpers/procedure_helper.rb index 17a757d93..922479ec5 100644 --- a/app/helpers/procedure_helper.rb +++ b/app/helpers/procedure_helper.rb @@ -38,9 +38,15 @@ module ProcedureHelper } end - def show_auto_archive(procedure) + def procedure_auto_archive_date(procedure) I18n.l(procedure.auto_archive_on - 1.day, format: '%-d %B %Y') end - private + def procedure_auto_archive_time(procedure) + "à 23 h 59 (heure de " + Rails.application.config.time_zone + ")" + end + + def procedure_auto_archive_datetime(procedure) + procedure_auto_archive_date(procedure) + ' ' + procedure_auto_archive_time(procedure) + end end diff --git a/app/views/dossier_mailer/notify_brouillon_not_submitted.html.haml b/app/views/dossier_mailer/notify_brouillon_not_submitted.html.haml index 43c4b64f0..7d23c6853 100644 --- a/app/views/dossier_mailer/notify_brouillon_not_submitted.html.haml +++ b/app/views/dossier_mailer/notify_brouillon_not_submitted.html.haml @@ -10,7 +10,7 @@  » est commencé mais n'est pas encore déposé. %p Si vous souhaitez que ce dossier soit pris en compte, il vous faut le déposer avant le - #{show_auto_archive(@dossier.procedure)} à 23 h 59 (heure de #{Rails.application.config.time_zone}), date limite de dépôt des dossiers. + #{procedure_auto_archive_datetime(@dossier.procedure)}, date limite de dépôt des dossiers. %p Pour cela, affichez le dossier avec le bouton ci-dessous, vérifiez votre dossier puis cliquez sur le bouton diff --git a/app/views/dossier_mailer/notify_new_draft.html.haml b/app/views/dossier_mailer/notify_new_draft.html.haml index 337c8c351..af36f69b3 100644 --- a/app/views/dossier_mailer/notify_new_draft.html.haml +++ b/app/views/dossier_mailer/notify_new_draft.html.haml @@ -18,7 +18,7 @@ - if @dossier.procedure.auto_archive_on %p - Vous pouvez déposer votre dossier jusqu'au #{show_auto_archive(@dossier.procedure)} à 23 h 59 (heure de #{Rails.application.config.time_zone}). + Vous pouvez déposer votre dossier jusqu'au #{procedure_auto_archive_datetime(@dossier.procedure)}. = render 'layouts/mailers/signature' diff --git a/app/views/new_administrateur/procedures/_informations.html.haml b/app/views/new_administrateur/procedures/_informations.html.haml index ff90d71e3..2602231ea 100644 --- a/app/views/new_administrateur/procedures/_informations.html.haml +++ b/app/views/new_administrateur/procedures/_informations.html.haml @@ -115,7 +115,7 @@ Le - value = @procedure.auto_archive_on ? @procedure.auto_archive_on - 1.day : nil = f.date_field :auto_archive_on, id: 'auto_archive_on', value: value - à 23 h 59 (heure de #{Rails.application.config.time_zone}). + #{procedure_auto_archive_time(@procedure)}. = f.label :declarative_with_state do Démarche déclarative diff --git a/app/views/shared/_procedure_description.html.haml b/app/views/shared/_procedure_description.html.haml index ba241bda0..9c1c4c1f6 100644 --- a/app/views/shared/_procedure_description.html.haml +++ b/app/views/shared/_procedure_description.html.haml @@ -13,8 +13,8 @@ %summary %span.icon.clock - %span.procedure-auto-archive-title Date limite : #{show_auto_archive(procedure)} - %p Vous pouvez déposer vos dossiers jusqu'au #{show_auto_archive(procedure)} à 23 h 59 (heure de #{Rails.application.config.time_zone}). + %span.procedure-auto-archive-title Date limite : #{procedure_auto_archive_date(procedure)} + %p Vous pouvez déposer vos dossiers jusqu'au #{procedure_auto_archive_datetime(procedure)}. .procedure-description .procedure-description-body.read-more-enabled.read-more-collapsed diff --git a/spec/helpers/procedure_helper_spec.rb b/spec/helpers/procedure_helper_spec.rb index 43476eeae..288c10e77 100644 --- a/spec/helpers/procedure_helper_spec.rb +++ b/spec/helpers/procedure_helper_spec.rb @@ -1,10 +1,10 @@ RSpec.describe ProcedureHelper, type: :helper do let(:auto_archive_date) { Time.zone.local(2020, 8, 2, 12, 00) } - let(:procedure) { create(:procedure, auto_archive_on: auto_archive_date) } + let(:procedure) { build(:procedure, auto_archive_on: auto_archive_date) } - subject { show_auto_archive(procedure) } + subject { procedure_auto_archive_datetime(procedure) } it "displays the day before the auto archive date (to account for the '23h59' ending time)" do - expect(subject).to eq "1 août 2020" + expect(subject).to have_text("1 août 2020 à 23 h 59 (heure de Paris)") end end