From eb3d2cb20cc28ad1aef21ada4c0c7070fff12cb1 Mon Sep 17 00:00:00 2001 From: mfo Date: Fri, 13 Sep 2024 11:17:16 +0200 Subject: [PATCH] bug(normalized_address): should not raise an error for addresses without code postal --- .../_normalized_address.html.haml_spec.rb | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/spec/views/shared/dossiers/_normalized_address.html.haml_spec.rb b/spec/views/shared/dossiers/_normalized_address.html.haml_spec.rb index 1ce482ca4..9e1a722e3 100644 --- a/spec/views/shared/dossiers/_normalized_address.html.haml_spec.rb +++ b/spec/views/shared/dossiers/_normalized_address.html.haml_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true 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 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 AddressProxy::ADDRESS_PARTS.each do |address_part| - expect(rendered).to have_text(address_part) + expect(subject).to have_text(address_part) end end end @@ -20,12 +20,22 @@ describe 'shared/dossiers/normalized_address', type: :view do let(:address) { AddressProxy.new(etablissement) } it 'render address' do - expect(rendered).to have_text("6 RUE RAOUL NORDLING") - expect(rendered).to have_text("BOIS COLOMBES 92270") - expect(rendered).to have_text("92009") - expect(rendered).to have_text("92270") - expect(rendered).to have_text("Hauts-de-Seine – 92") - expect(rendered).to have_text("Île-de-France – 11") + expect(subject).to have_text("6 RUE RAOUL NORDLING") + expect(subject).to have_text("BOIS COLOMBES 92270") + expect(subject).to have_text("92009") + expect(subject).to have_text("92270") + expect(subject).to have_text("Hauts-de-Seine – 92") + 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