spec(normalized_address): add simple spec

This commit is contained in:
mfo 2024-08-22 10:18:50 +02:00
parent 7182a4e8d0
commit 70983c50f9
No known key found for this signature in database
GPG key ID: 7CE3E1F5B794A8EC
4 changed files with 34 additions and 2 deletions

View file

@ -41,7 +41,7 @@ class AddressProxy
delegate(*ADDRESS_PARTS, to: :@presenter)
def initialize(champs_or_etablissement)
def initialize(champ_or_etablissement)
@presenter = make(champ_or_etablissement)
end

View file

@ -163,6 +163,7 @@ FactoryBot.define do
factory :champ_do_not_use_siret, class: 'Champs::SiretChamp' do
association :etablissement, factory: [:etablissement]
value { '44011762001530' }
value_json { AddressProxy::ADDRESS_PARTS.index_by(&:itself) }
end
factory :champ_do_not_use_rna, class: 'Champs::RNAChamp' do

View file

@ -12,7 +12,7 @@ module Maintenance
it 'updates value_json' do
expect { subject }.to change { element.reload.value_json }
.from(nil)
.from(anything)
.to({
"city_code" => "92009",
"city_name" => "Bois-Colombes",

View file

@ -0,0 +1,31 @@
# frozen_string_literal: true
describe 'shared/dossiers/normalized_address', type: :view do
before { render 'shared/dossiers/normalized_address', address: }
context 'given an champ' do
let(:procedure) { create(:procedure, types_de_champ_public: [{ type: :siret }]) }
let(:dossier) { create(:dossier, :with_populated_champs, procedure:) }
let(:address) { AddressProxy.new(dossier.champs.first) }
it 'render address' do
AddressProxy::ADDRESS_PARTS.each do |address_part|
expect(rendered).to have_text(address_part)
end
end
end
context 'given an etablissement' do
let(:etablissement) { create(:etablissement) }
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")
end
end
end