Merge pull request #5201 from betagouv/dev

2020-05-28-02
This commit is contained in:
krichtof 2020-05-28 17:44:19 +02:00 committed by GitHub
commit fd1e1914b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 115 additions and 13 deletions

View file

@ -8,17 +8,11 @@ jobs:
if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/rebase')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Checkout the latest code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Automatic Rebase
uses: cirrus-actions/rebase@1.2
uses: cirrus-actions/rebase@1.3.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# https://github.community/t5/GitHub-Actions/Workflow-is-failing-if-no-job-can-be-ran-due-to-condition/m-p/38186#M3250
always_job:
name: Always run job
runs-on: ubuntu-latest
steps:
- name: Always run
run: echo "This job is used to prevent the workflow to fail when all other jobs are skipped."

View file

@ -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;

View file

@ -38,5 +38,15 @@ module ProcedureHelper
}
end
private
def procedure_auto_archive_date(procedure)
I18n.l(procedure.auto_archive_on - 1.day, format: '%-d %B %Y')
end
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

View file

@ -2,6 +2,7 @@
class DossierMailer < ApplicationMailer
helper ServiceHelper
helper MailerHelper
helper ProcedureHelper
layout 'mailers/layout'

View file

@ -10,7 +10,7 @@
&nbsp;» 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.
#{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

View file

@ -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 #{procedure_auto_archive_datetime(@dossier.procedure)}.
= render 'layouts/mailers/signature'
- content_for :footer do

View file

@ -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
#{procedure_auto_archive_time(@procedure)}.
= f.label :declarative_with_state do
Démarche déclarative

View file

@ -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 : #{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
= h string_to_html(procedure.description)

View file

@ -0,0 +1,20 @@
namespace :after_party do
desc 'Deployment task: fix_dossier_etablissement'
task fix_dossier_etablissement: :environment do
puts "Running deploy task 'fix_dossier_etablissement'"
etablissements = Etablissement.joins(:champ).where.not(dossier_id: nil).where('etablissements.created_at > ?', 1.month.ago)
dossiers_modif = []
etablissements.find_each do |e|
if e.dossier
dossier = e.dossier
e.update!(dossier_id: nil)
dossier.reload.etablissement = e.reload.dup
dossier.save!
dossiers_modif << dossier.id
end
end
puts "Nb dossiers modifiés: #{dossiers_modif.size}"
AfterParty::TaskRecord.create version: '20200528124044'
end
end

View file

@ -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 }

View file

@ -0,0 +1,10 @@
RSpec.describe ProcedureHelper, type: :helper do
let(:auto_archive_date) { Time.zone.local(2020, 8, 2, 12, 00) }
let(:procedure) { build(:procedure, auto_archive_on: auto_archive_date) }
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 have_text("1 août 2020 à 23 h 59 (heure de Paris)")
end
end

View file

@ -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,8 @@ 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 { expect(subject.body).to include("heure de") }
it_behaves_like 'a dossier notification'
end

View file

@ -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