[#3424] Improve formatting of addresses with missing components
This commit is contained in:
parent
8750d0e410
commit
41ab7246cf
2 changed files with 11 additions and 1 deletions
|
@ -45,7 +45,11 @@ class Etablissement < ApplicationRecord
|
|||
|
||||
def inline_adresse
|
||||
# squeeze needed because of space in excess in the data
|
||||
"#{numero_voie} #{type_voie} #{nom_voie}, #{complement_adresse}, #{code_postal} #{localite}".squeeze(' ')
|
||||
[
|
||||
"#{numero_voie} #{type_voie} #{nom_voie}",
|
||||
complement_adresse,
|
||||
"#{code_postal} #{localite}"
|
||||
].map { |s| s.squeeze(' ') }.reject(&:blank?).join(', ')
|
||||
end
|
||||
|
||||
def verify
|
||||
|
|
|
@ -13,6 +13,12 @@ describe Etablissement do
|
|||
let(:etablissement) { create(:etablissement, nom_voie: 'green moon') }
|
||||
|
||||
it { expect(etablissement.inline_adresse).to eq '6 RUE green moon, IMMEUBLE BORA, 92270 BOIS COLOMBES' }
|
||||
|
||||
context 'with missing complement adresse' do
|
||||
let(:etablissement) { create(:etablissement, complement_adresse: '') }
|
||||
|
||||
it { expect(etablissement.inline_adresse).to eq '6 RUE RAOUL NORDLING, 92270 BOIS COLOMBES' }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#verify' do
|
||||
|
|
Loading…
Reference in a new issue