Merge pull request #2040 from betagouv/frederic/fix-1946/show-retention-time-in-administration

[#1946] Show retention times in procedure administration summary
This commit is contained in:
Frederic Merizen 2018-06-01 17:54:41 +02:00 committed by GitHub
commit ece58290de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 65 additions and 0 deletions

View file

@ -0,0 +1,19 @@
module ConservationDeDonneesHelper
def politiques_conservation_de_donnees(procedure)
[conservation_dans_ds(procedure), conservation_hors_ds(procedure)].compact
end
private
def conservation_dans_ds(procedure)
if procedure.duree_conservation_dossiers_dans_ds.present?
"dans demarches-simplifiees.fr #{procedure.duree_conservation_dossiers_dans_ds} mois après le début de linstruction du dossier"
end
end
def conservation_hors_ds(procedure)
if procedure.duree_conservation_dossiers_hors_ds.present?
"hors demarches-simplifiees.fr pendant #{procedure.duree_conservation_dossiers_hors_ds} mois"
end
end
end

View file

@ -96,6 +96,15 @@
- procedure.types_de_piece_justificative.each do |piece_justificative|
= piece_justificative.libelle
%br
- durees_de_conservation = politiques_conservation_de_donnees(procedure)
- if durees_de_conservation.present?
.row{ style: 'margin-right: 3%; margin-left: 3%;' }
.col-xs-6.col-md-3
%h4.text-info Conservation des données
- durees_de_conservation.each do |text|
%p = text
%br
%h3
= t('dynamics.admin.procedure.stats.title')

View file

@ -0,0 +1,37 @@
require 'rails_helper'
RSpec.describe ConservationDeDonneesHelper, type: :helper do
let(:procedure) { build(:procedure, duree_conservation_dossiers_dans_ds: dans_ds, duree_conservation_dossiers_hors_ds: hors_ds) }
describe "politiques_conservation_de_donnees" do
subject { politiques_conservation_de_donnees(procedure) }
context "when both retention times are set" do
let(:dans_ds) { 3 }
let(:hors_ds) { 6 }
it { is_expected.to eq([ "dans demarches-simplifiees.fr 3 mois après le début de linstruction du dossier", "hors demarches-simplifiees.fr pendant 6 mois" ]) }
end
context "when only in-app retention time is set" do
let(:dans_ds) { 3 }
let(:hors_ds) { nil }
it { is_expected.to eq([ "dans demarches-simplifiees.fr 3 mois après le début de linstruction du dossier" ]) }
end
context "when only out of app retention time is set" do
let(:dans_ds) { nil }
let(:hors_ds) { 6 }
it { is_expected.to eq([ "hors demarches-simplifiees.fr pendant 6 mois" ]) }
end
context "when the retention time is not set" do
let(:dans_ds) { nil }
let(:hors_ds) { nil }
it { is_expected.to be_empty }
end
end
end