From c6082ded090ba080b2f5dc56ab4c98f838f53f11 Mon Sep 17 00:00:00 2001 From: Eric Leroy-Terquem Date: Fri, 7 Oct 2022 18:37:41 +0200 Subject: [PATCH 1/2] no select for usager if only one groupe_instructeur --- app/models/dossier.rb | 2 +- app/models/procedure.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 348e0cd6c..064e8ae6c 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -614,7 +614,7 @@ class Dossier < ApplicationRecord end def show_groupe_instructeur_selector? - procedure.routee? && !procedure.feature_enabled?(:procedure_routage_api) + procedure.routee? && !procedure.feature_enabled?(:procedure_routage_api) && procedure.groupe_instructeurs.size > 1 end def assign_to_groupe_instructeur(groupe_instructeur, author = nil) diff --git a/app/models/procedure.rb b/app/models/procedure.rb index c8beda2e3..4576522c4 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -691,7 +691,7 @@ class Procedure < ApplicationRecord end def defaut_groupe_instructeur_for_new_dossier - if !routee? || feature_enabled?(:procedure_routage_api) + if !routee? || feature_enabled?(:procedure_routage_api) || (routee? && self.groupe_instructeurs.size == 1) defaut_groupe_instructeur end end From 2147a1865c14e8f2464aacca185aea518e55f6c4 Mon Sep 17 00:00:00 2001 From: Eric Leroy-Terquem Date: Mon, 10 Oct 2022 18:03:47 +0200 Subject: [PATCH 2/2] add test --- spec/system/users/brouillon_spec.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/spec/system/users/brouillon_spec.rb b/spec/system/users/brouillon_spec.rb index 45868d19c..54303225d 100644 --- a/spec/system/users/brouillon_spec.rb +++ b/spec/system/users/brouillon_spec.rb @@ -242,6 +242,29 @@ describe 'The user' do expect(page).to have_text('file.pdf') end + context 'with routing activated and one instructor group' do + let!(:simple_procedure) { create(:simple_procedure, :published, :with_type_de_champ, :for_individual) } + let!(:administrateur) { create(:administrateur, procedures: [simple_procedure]) } + + before do + simple_procedure.update(routing_enabled: true) + simple_procedure.defaut_groupe_instructeur.instructeurs << administrateur.instructeur + end + + it 'sends the dossier without selecting instructor group', js: true do + log_in(user, simple_procedure) + fill_individual + fill_in('Texte obligatoire', with: 'bla bla') + wait_for_autosave + + expect(page).not_to have_text('Votre ville') + + click_on 'Déposer le dossier' + + expect(page).to have_text('Merci') + end + end + context 'with condition' do include Logic