spec(normalized_address): add simple spec
This commit is contained in:
parent
7182a4e8d0
commit
70983c50f9
4 changed files with 34 additions and 2 deletions
|
@ -41,7 +41,7 @@ class AddressProxy
|
||||||
|
|
||||||
delegate(*ADDRESS_PARTS, to: :@presenter)
|
delegate(*ADDRESS_PARTS, to: :@presenter)
|
||||||
|
|
||||||
def initialize(champs_or_etablissement)
|
def initialize(champ_or_etablissement)
|
||||||
@presenter = make(champ_or_etablissement)
|
@presenter = make(champ_or_etablissement)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -163,6 +163,7 @@ FactoryBot.define do
|
||||||
factory :champ_do_not_use_siret, class: 'Champs::SiretChamp' do
|
factory :champ_do_not_use_siret, class: 'Champs::SiretChamp' do
|
||||||
association :etablissement, factory: [:etablissement]
|
association :etablissement, factory: [:etablissement]
|
||||||
value { '44011762001530' }
|
value { '44011762001530' }
|
||||||
|
value_json { AddressProxy::ADDRESS_PARTS.index_by(&:itself) }
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :champ_do_not_use_rna, class: 'Champs::RNAChamp' do
|
factory :champ_do_not_use_rna, class: 'Champs::RNAChamp' do
|
||||||
|
|
|
@ -12,7 +12,7 @@ module Maintenance
|
||||||
|
|
||||||
it 'updates value_json' do
|
it 'updates value_json' do
|
||||||
expect { subject }.to change { element.reload.value_json }
|
expect { subject }.to change { element.reload.value_json }
|
||||||
.from(nil)
|
.from(anything)
|
||||||
.to({
|
.to({
|
||||||
"city_code" => "92009",
|
"city_code" => "92009",
|
||||||
"city_name" => "Bois-Colombes",
|
"city_name" => "Bois-Colombes",
|
||||||
|
|
|
@ -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
|
Loading…
Reference in a new issue