diff --git a/app/views/instructeurs/dossiers/print.html.haml b/app/views/instructeurs/dossiers/print.html.haml index 7702f8ed4..25bfa2aec 100644 --- a/app/views/instructeurs/dossiers/print.html.haml +++ b/app/views/instructeurs/dossiers/print.html.haml @@ -14,7 +14,7 @@ %h2 Formulaire - champs = @dossier.champs -- if champs.any? +- if champs.any? || @dossier.procedure.routee? = render partial: "shared/dossiers/champs", locals: { champs: champs, dossier: @dossier, demande_seen_at: nil, profile: 'instructeur' } %h2 Annotations privées diff --git a/app/views/shared/dossiers/_champs.html.haml b/app/views/shared/dossiers/_champs.html.haml index 1a511730f..969c489d5 100644 --- a/app/views/shared/dossiers/_champs.html.haml +++ b/app/views/shared/dossiers/_champs.html.haml @@ -1,3 +1,7 @@ %table.table.vertical.dossier-champs %tbody + - if dossier.procedure.routee? + %th= dossier.procedure.routing_criteria_name + %td= dossier.groupe_instructeur.label + %td = render partial: "shared/dossiers/champ_row", locals: { champs: champs, demande_seen_at: demande_seen_at, profile: profile, repetition: false } diff --git a/app/views/shared/dossiers/_demande.html.haml b/app/views/shared/dossiers/_demande.html.haml index d04cc1918..55870541c 100644 --- a/app/views/shared/dossiers/_demande.html.haml +++ b/app/views/shared/dossiers/_demande.html.haml @@ -23,6 +23,6 @@ .tab-title Formulaire - champs = dossier.champs.includes(:type_de_champ) - - if champs.any? + - if champs.any? || dossier.procedure.routee? .card - = render partial: "shared/dossiers/champs", locals: { champs: champs, demande_seen_at: demande_seen_at, profile: profile } + = render partial: "shared/dossiers/champs", locals: { champs: champs, dossier: dossier, demande_seen_at: demande_seen_at, profile: profile } diff --git a/spec/factories/procedure.rb b/spec/factories/procedure.rb index 3cfdd52dc..43dc38211 100644 --- a/spec/factories/procedure.rb +++ b/spec/factories/procedure.rb @@ -74,6 +74,12 @@ FactoryBot.define do end end + trait :routee do + after(:create) do |procedure, _evaluator| + procedure.groupe_instructeurs.create(label: '2nd groupe') + end + end + trait :for_individual do after(:build) do |procedure, _evaluator| procedure.for_individual = true diff --git a/spec/views/shared/dossiers/_champs.html.haml_spec.rb b/spec/views/shared/dossiers/_champs.html.haml_spec.rb index dfce7ae25..9efff5573 100644 --- a/spec/views/shared/dossiers/_champs.html.haml_spec.rb +++ b/spec/views/shared/dossiers/_champs.html.haml_spec.rb @@ -8,7 +8,7 @@ describe 'shared/dossiers/champs.html.haml', type: :view do allow(view).to receive(:current_instructeur).and_return(instructeur) end - subject { render 'shared/dossiers/champs.html.haml', champs: champs, demande_seen_at: demande_seen_at, profile: nil } + subject { render 'shared/dossiers/champs.html.haml', champs: champs, dossier: dossier, demande_seen_at: demande_seen_at, profile: nil } context "there are some champs" do let(:dossier) { create(:dossier) } @@ -54,6 +54,21 @@ describe 'shared/dossiers/champs.html.haml', type: :view do end end + context "with a routed procedure" do + let(:procedure) do + create(:procedure, + :routee, + routing_criteria_name: 'departement') + end + let(:dossier) { create(:dossier, procedure: procedure) } + let(:champs) { [] } + + it "renders the routing criteria name and its value" do + expect(subject).to include(procedure.routing_criteria_name) + expect(subject).to include(dossier.groupe_instructeur.label) + end + end + context "with a dossier champ, but we are not authorized to acces the dossier" do let(:dossier) { create(:dossier) } let(:champ) { create(:champ, :dossier_link, value: dossier.id) } @@ -65,6 +80,7 @@ describe 'shared/dossiers/champs.html.haml', type: :view do end context "with a dossier_link champ but without value" do + let(:dossier) { create(:dossier) } let(:champ) { create(:champ, :dossier_link, value: nil) } let(:champs) { [champ] }