Merge pull request #9294 from colinux/fix-entreprise-without-siret-siege

Fix (demande): pas d'erreur lorsque l'entreprie n'a pas de SIRET associé au siège social
This commit is contained in:
Colin Darie 2023-07-10 14:09:23 +00:00 committed by GitHub
commit e2a9978c26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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