Merge pull request #8425 from adullact/fix/procedure-custom-retention
Fix du support d'une durée personnalisée de conservation des dossiers
This commit is contained in:
commit
1926aa283d
3 changed files with 25 additions and 2 deletions
|
@ -115,7 +115,11 @@ module Administrateurs
|
|||
end
|
||||
|
||||
def create
|
||||
@procedure = Procedure.new(procedure_params.merge(administrateurs: [current_administrateur]))
|
||||
new_procedure_params = { max_duree_conservation_dossiers_dans_ds: Procedure::NEW_MAX_DUREE_CONSERVATION }
|
||||
.merge(procedure_params)
|
||||
.merge(administrateurs: [current_administrateur])
|
||||
|
||||
@procedure = Procedure.new(new_procedure_params)
|
||||
@procedure.draft_revision = @procedure.revisions.build
|
||||
|
||||
if !@procedure.save
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
= t(:notice, scope: [:administrateurs, :duree_conservation_dossiers_dans_ds])
|
||||
- if f.object.duree_conservation_dossiers_dans_ds.to_i < Procedure::NEW_MAX_DUREE_CONSERVATION
|
||||
= t(:new_duration_constraint, scope: [:administrateurs, :duree_conservation_dossiers_dans_ds], new_duration_in_month: Procedure::NEW_MAX_DUREE_CONSERVATION)
|
||||
= f.number_field :duree_conservation_dossiers_dans_ds, { class: 'form-control', placeholder: '6', required: true }.merge(f.object.duree_conservation_etendue_par_ds ? {} : { max: 12 })
|
||||
= f.number_field :duree_conservation_dossiers_dans_ds, { class: 'form-control', placeholder: '6', required: true }.merge(f.object.duree_conservation_etendue_par_ds ? {} : { max: Procedure::NEW_MAX_DUREE_CONSERVATION })
|
||||
|
||||
- if @procedure.created_at.present?
|
||||
= f.label :lien_site_web do
|
||||
|
|
|
@ -342,6 +342,25 @@ describe Administrateurs::ProceduresController, type: :controller do
|
|||
it { expect(flash[:notice]).to be_present }
|
||||
end
|
||||
|
||||
describe "procedure is saved with custom retention period" do
|
||||
let(:duree_conservation_dossiers_dans_ds) { 17 }
|
||||
|
||||
before do
|
||||
stub_const("Procedure::NEW_MAX_DUREE_CONSERVATION", 18)
|
||||
end
|
||||
|
||||
subject { post :create, params: { procedure: procedure_params } }
|
||||
|
||||
it { expect { subject }.to change { Procedure.count }.by(1) }
|
||||
|
||||
it "must save retention period and max retention period" do
|
||||
subject
|
||||
last_procedure = Procedure.last
|
||||
expect(last_procedure.duree_conservation_dossiers_dans_ds).to eq(duree_conservation_dossiers_dans_ds)
|
||||
expect(last_procedure.max_duree_conservation_dossiers_dans_ds).to eq(Procedure::NEW_MAX_DUREE_CONSERVATION)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when procedure is correctly saved' do
|
||||
let(:instructeur) { admin.instructeur }
|
||||
|
||||
|
|
Loading…
Reference in a new issue