Display the dossier.groupe_instructeur.label on various screens

This commit is contained in:
simon lehericey 2019-10-15 10:29:07 +02:00
parent b7434c3132
commit 18de25fac7
5 changed files with 30 additions and 4 deletions

View file

@ -14,7 +14,7 @@
%h2 Formulaire %h2 Formulaire
- champs = @dossier.champs - 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' } = render partial: "shared/dossiers/champs", locals: { champs: champs, dossier: @dossier, demande_seen_at: nil, profile: 'instructeur' }
%h2 Annotations privées %h2 Annotations privées

View file

@ -1,3 +1,7 @@
%table.table.vertical.dossier-champs %table.table.vertical.dossier-champs
%tbody %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 } = render partial: "shared/dossiers/champ_row", locals: { champs: champs, demande_seen_at: demande_seen_at, profile: profile, repetition: false }

View file

@ -23,6 +23,6 @@
.tab-title Formulaire .tab-title Formulaire
- champs = dossier.champs.includes(:type_de_champ) - champs = dossier.champs.includes(:type_de_champ)
- if champs.any? - if champs.any? || dossier.procedure.routee?
.card .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 }

View file

@ -74,6 +74,12 @@ FactoryBot.define do
end end
end end
trait :routee do
after(:create) do |procedure, _evaluator|
procedure.groupe_instructeurs.create(label: '2nd groupe')
end
end
trait :for_individual do trait :for_individual do
after(:build) do |procedure, _evaluator| after(:build) do |procedure, _evaluator|
procedure.for_individual = true procedure.for_individual = true

View file

@ -8,7 +8,7 @@ describe 'shared/dossiers/champs.html.haml', type: :view do
allow(view).to receive(:current_instructeur).and_return(instructeur) allow(view).to receive(:current_instructeur).and_return(instructeur)
end 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 context "there are some champs" do
let(:dossier) { create(:dossier) } let(:dossier) { create(:dossier) }
@ -54,6 +54,21 @@ describe 'shared/dossiers/champs.html.haml', type: :view do
end end
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 context "with a dossier champ, but we are not authorized to acces the dossier" do
let(:dossier) { create(:dossier) } let(:dossier) { create(:dossier) }
let(:champ) { create(:champ, :dossier_link, value: dossier.id) } let(:champ) { create(:champ, :dossier_link, value: dossier.id) }
@ -65,6 +80,7 @@ describe 'shared/dossiers/champs.html.haml', type: :view do
end end
context "with a dossier_link champ but without value" do context "with a dossier_link champ but without value" do
let(:dossier) { create(:dossier) }
let(:champ) { create(:champ, :dossier_link, value: nil) } let(:champ) { create(:champ, :dossier_link, value: nil) }
let(:champs) { [champ] } let(:champs) { [champ] }