Merge pull request #8968 from demarches-simplifiees/fix_defaut_groupe_instructeur_again

Correctif: definit le groupe instructeur par defaut pour certaines procedure clonées
This commit is contained in:
Paul Chavard 2023-04-26 16:51:40 +00:00 committed by GitHub
commit 0e03ab653a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 4 deletions

View file

@ -580,7 +580,8 @@ class Procedure < ApplicationRecord
procedure.draft_revision.types_de_champ_public.each { |tdc| tdc.options&.delete(:old_pj) }
end
new_defaut_groupe = procedure.groupe_instructeurs.find_by(label: defaut_groupe_instructeur.label)
new_defaut_groupe = procedure.groupe_instructeurs
.find_by(label: defaut_groupe_instructeur.label) || procedure.groupe_instructeurs.first
procedure.update!(defaut_groupe_instructeur: new_defaut_groupe)
procedure

View file

@ -504,13 +504,12 @@ describe Procedure do
let!(:assign_to_1) { create(:assign_to, procedure: procedure, groupe_instructeur: groupe_instructeur_1, instructeur: instructeur_1) }
let!(:assign_to_2) { create(:assign_to, procedure: procedure, groupe_instructeur: groupe_instructeur_1, instructeur: instructeur_2) }
before do
subject do
@procedure = procedure.clone(administrateur, from_library)
@procedure.save
@procedure
end
subject { @procedure }
it { expect(subject.parent_procedure).to eq(procedure) }
describe "should keep groupe instructeurs " do
@ -623,6 +622,16 @@ describe Procedure do
let(:administrateur) { create(:administrateur) }
let(:opendata) { false }
context 'and the procedure does not have a groupe with the defaut label' do
before do
procedure.defaut_groupe_instructeur.update!(label: 'another label')
end
it "affects the first groupe as the defaut groupe" do
expect(subject.defaut_groupe_instructeur).to eq(subject.groupe_instructeurs.first)
end
end
it 'should not clone service' do
expect(subject.service).to eq(nil)
end