diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 2b2c06d65..23f668b3c 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -489,6 +489,7 @@ class Procedure < ApplicationRecord procedure.duree_conservation_etendue_par_ds = false if procedure.duree_conservation_dossiers_dans_ds > NEW_MAX_DUREE_CONSERVATION procedure.duree_conservation_dossiers_dans_ds = NEW_MAX_DUREE_CONSERVATION + procedure.max_duree_conservation_dossiers_dans_ds = NEW_MAX_DUREE_CONSERVATION end procedure.published_revision = nil procedure.draft_revision.procedure = procedure diff --git a/spec/factories/procedure.rb b/spec/factories/procedure.rb index 3a4d76c26..755c70abd 100644 --- a/spec/factories/procedure.rb +++ b/spec/factories/procedure.rb @@ -9,6 +9,7 @@ FactoryBot.define do cadre_juridique { "un cadre juridique important" } published_at { nil } duree_conservation_dossiers_dans_ds { 3 } + max_duree_conservation_dossiers_dans_ds { Procedure::OLD_MAX_DUREE_CONSERVATION } ask_birthday { false } lien_site_web { "https://mon-site.gouv" } path { SecureRandom.uuid } diff --git a/spec/models/procedure_spec.rb b/spec/models/procedure_spec.rb index 36cd58f3f..5b1924c31 100644 --- a/spec/models/procedure_spec.rb +++ b/spec/models/procedure_spec.rb @@ -284,7 +284,7 @@ describe Procedure do describe 'duree de conservation dans ds' do let(:field_name) { :duree_conservation_dossiers_dans_ds } context 'by default is caped to 12' do - subject { create(:procedure, duree_conservation_dossiers_dans_ds: 12) } + subject { create(:procedure, duree_conservation_dossiers_dans_ds: 12, max_duree_conservation_dossiers_dans_ds: 12) } it { is_expected.not_to allow_value(nil).for(field_name) } it { is_expected.not_to allow_value('').for(field_name) } it { is_expected.not_to allow_value('trois').for(field_name) } @@ -448,6 +448,7 @@ describe Procedure do opendata: opendata, duree_conservation_etendue_par_ds: true, duree_conservation_dossiers_dans_ds: Procedure::OLD_MAX_DUREE_CONSERVATION, + max_duree_conservation_dossiers_dans_ds: Procedure::OLD_MAX_DUREE_CONSERVATION, attestation_template: build(:attestation_template, logo: logo, signature: signature), types_de_champ_public: [{}, {}, { type: :drop_down_list }, { type: :piece_justificative }, { type: :repetition, children: [{}] }], types_de_champ_private: [{}, {}, { type: :drop_down_list }, { type: :repetition, children: [{}] }], @@ -531,7 +532,7 @@ describe Procedure do cloned_procedure = subject cloned_procedure.parent_procedure_id = nil - expect(cloned_procedure).to have_same_attributes_as(procedure, except: ["path", "draft_revision_id", "service_id", "duree_conservation_etendue_par_ds", "duree_conservation_dossiers_dans_ds"]) + expect(cloned_procedure).to have_same_attributes_as(procedure, except: ["path", "draft_revision_id", "service_id", "duree_conservation_etendue_par_ds", "duree_conservation_dossiers_dans_ds", 'max_duree_conservation_dossiers_dans_ds']) end context 'which is opendata' do