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:
commit
ece58290de
3 changed files with 65 additions and 0 deletions
19
app/helpers/conservation_de_donnees_helper.rb
Normal file
19
app/helpers/conservation_de_donnees_helper.rb
Normal 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 l’instruction 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
|
|
@ -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')
|
||||
|
|
37
spec/helpers/conservation_de_donnees_helper_spec.rb
Normal file
37
spec/helpers/conservation_de_donnees_helper_spec.rb
Normal 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 l’instruction 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 l’instruction 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
|
Loading…
Reference in a new issue