fix(dossier): improuve commune champ rendering in pdf
This commit is contained in:
parent
ed33f1916a
commit
2a48228552
4 changed files with 14 additions and 7 deletions
|
@ -25,7 +25,7 @@ class Champs::CommuneChamp < Champs::TextChamp
|
||||||
before_validation :on_code_postal_change
|
before_validation :on_code_postal_change
|
||||||
|
|
||||||
def for_export
|
def for_export
|
||||||
[name, code, departement? ? departement_code_and_name : '']
|
[name, code? ? code : '', departement? ? departement_code_and_name : '']
|
||||||
end
|
end
|
||||||
|
|
||||||
def departement_name
|
def departement_name
|
||||||
|
|
|
@ -170,14 +170,14 @@ def add_single_champ(pdf, champ)
|
||||||
add_identite_etablissement(pdf, champ.etablissement)
|
add_identite_etablissement(pdf, champ.etablissement)
|
||||||
end
|
end
|
||||||
when 'Champs::NumberChamp'
|
when 'Champs::NumberChamp'
|
||||||
value = champ.to_s.empty? ? 'Non communiqué' : number_with_delimiter(champ.to_s)
|
value = champ.blank? ? 'Non communiqué' : number_with_delimiter(champ.to_s)
|
||||||
format_in_2_lines(pdf, tdc.libelle, value)
|
format_in_2_lines(pdf, tdc.libelle, value)
|
||||||
when 'Champs::CommuneChamp'
|
when 'Champs::CommuneChamp'
|
||||||
value = champ.to_s.empty? ? 'Non communiqué' : champ.to_s
|
value = champ.blank? ? 'Non communiqué' : champ.to_s
|
||||||
format_in_2_lines(pdf, tdc.libelle, value)
|
format_in_2_lines(pdf, tdc.libelle, value)
|
||||||
pdf.text "Département : #{champ.departement}" if champ.departement.present?
|
pdf.text "Département : #{champ.departement_code_and_name}" if champ.departement?
|
||||||
else
|
else
|
||||||
value = champ.to_s.empty? ? 'Non communiqué' : champ.to_s
|
value = champ.blank? ? 'Non communiqué' : champ.to_s
|
||||||
format_in_2_lines(pdf, tdc.libelle, value)
|
format_in_2_lines(pdf, tdc.libelle, value)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -738,6 +738,13 @@ describe Instructeurs::DossiersController, type: :controller do
|
||||||
it { expect(assigns(:include_infos_administration)).to eq(true) }
|
it { expect(assigns(:include_infos_administration)).to eq(true) }
|
||||||
it { expect(assigns(:is_dossier_in_batch_operation)).to eq(false) }
|
it { expect(assigns(:is_dossier_in_batch_operation)).to eq(false) }
|
||||||
it { expect(response).to render_template 'dossiers/show' }
|
it { expect(response).to render_template 'dossiers/show' }
|
||||||
|
|
||||||
|
context 'empty champs commune' do
|
||||||
|
let(:procedure) { create(:procedure, :published, :with_commune, instructeurs:) }
|
||||||
|
let(:dossier) { create(:dossier, :accepte, procedure:) }
|
||||||
|
|
||||||
|
it { expect(response).to render_template 'dossiers/show' }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with dossier in batch_operation' do
|
context 'with dossier in batch_operation' do
|
||||||
|
|
|
@ -1680,8 +1680,8 @@ describe Dossier do
|
||||||
[
|
[
|
||||||
[yes_no_tdc.libelle, "Oui"],
|
[yes_no_tdc.libelle, "Oui"],
|
||||||
[text_tdc.libelle, "text"],
|
[text_tdc.libelle, "text"],
|
||||||
["commune", nil],
|
["commune", ''],
|
||||||
["commune (Code insee)", nil],
|
["commune (Code insee)", ''],
|
||||||
["commune (Département)", ""]
|
["commune (Département)", ""]
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue