fix(demande): don't crash when siret siege social is missing

This commit is contained in:
Colin Darie 2023-07-10 15:41:50 +02:00
parent d2f1af0830
commit e47761860a
2 changed files with 31 additions and 1 deletions

View file

@ -28,7 +28,7 @@
- unless local_assigns[:short_identity] - unless local_assigns[:short_identity]
- if etablissement.siret != etablissement.entreprise.siret_siege_social - if etablissement.entreprise.siret_siege_social.present? && etablissement.siret != etablissement.entreprise.siret_siege_social
= render Dossiers::RowShowComponent.new(label: "SIRET du siège social") do |c| = render Dossiers::RowShowComponent.new(label: "SIRET du siège social") do |c|
- c.with_value do - c.with_value do
%p %p

View file

@ -56,5 +56,35 @@ describe 'shared/dossiers/identite_entreprise', type: :view do
expect(rendered).to include("9 001") expect(rendered).to include("9 001")
end end
end end
context 'siret siege social' do
let(:etablissement) { create(:etablissement, siret: "12345678900001", entreprise_siret_siege_social: siret_siege_social) }
context 'when siege social has same siret' do
let(:siret_siege_social) { "12345678900001" }
it 'does not duplicate siret' do
expect(subject).to include("123 456 789 00001").once
end
end
context 'when siege social is different' do
let(:siret_siege_social) { "98765432100001" }
it 'shows both sirets' do
expect(subject).to include("123 456 789 00001")
expect(subject).to include("SIRET du siège social")
expect(subject).to include("987 654 321 00001")
end
end
context 'when siege social has no siret' do
let(:siret_siege_social) { nil }
it 'does not duplicate siret' do
expect(subject).not_to include("SIRET du siège social")
end
end
end
end end
end end