bug(normalized_address): should not raise an error for addresses without code postal

This commit is contained in:
mfo 2024-09-13 11:17:16 +02:00
parent d8a0adc6ed
commit eb3d2cb20c
No known key found for this signature in database
GPG key ID: 7CE3E1F5B794A8EC

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
describe 'shared/dossiers/normalized_address', type: :view do describe 'shared/dossiers/normalized_address', type: :view do
before { render 'shared/dossiers/normalized_address', address: } let(:subject) { render 'shared/dossiers/normalized_address', address: }
context 'given an champ' do context 'given an champ' do
let(:procedure) { create(:procedure, types_de_champ_public: [{ type: :siret }]) } let(:procedure) { create(:procedure, types_de_champ_public: [{ type: :siret }]) }
@ -10,7 +10,7 @@ describe 'shared/dossiers/normalized_address', type: :view do
it 'render address' do it 'render address' do
AddressProxy::ADDRESS_PARTS.each do |address_part| AddressProxy::ADDRESS_PARTS.each do |address_part|
expect(rendered).to have_text(address_part) expect(subject).to have_text(address_part)
end end
end end
end end
@ -20,12 +20,22 @@ describe 'shared/dossiers/normalized_address', type: :view do
let(:address) { AddressProxy.new(etablissement) } let(:address) { AddressProxy.new(etablissement) }
it 'render address' do it 'render address' do
expect(rendered).to have_text("6 RUE RAOUL NORDLING") expect(subject).to have_text("6 RUE RAOUL NORDLING")
expect(rendered).to have_text("BOIS COLOMBES 92270") expect(subject).to have_text("BOIS COLOMBES 92270")
expect(rendered).to have_text("92009") expect(subject).to have_text("92009")
expect(rendered).to have_text("92270") expect(subject).to have_text("92270")
expect(rendered).to have_text("Hauts-de-Seine 92") expect(subject).to have_text("Hauts-de-Seine 92")
expect(rendered).to have_text("Île-de-France 11") expect(subject).to have_text("Île-de-France 11")
end
end
context 'given a partial etablissement address' do
let(:etablissement) { create(:etablissement) }
before { allow(etablissement).to receive(:code_postal).and_return(nil) }
let(:address) { AddressProxy.new(etablissement) }
it 'render address' do
expect { subject }.not_to raise_error
end end
end end
end end