views: display auto-archive date on procedure description

This commit is contained in:
Judith 2020-05-27 11:25:43 +02:00 committed by GitHub Action
parent 59346ee868
commit 38eb60f2ac
5 changed files with 71 additions and 0 deletions

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

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 : #{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)

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) { 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

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