Merge pull request #3431 from betagouv/frederic/fix_nil
Fix undefined method for nil:NilClass
This commit is contained in:
commit
c3189ed34e
2 changed files with 20 additions and 3 deletions
|
@ -49,7 +49,7 @@ class Etablissement < ApplicationRecord
|
||||||
"#{numero_voie} #{type_voie} #{nom_voie}",
|
"#{numero_voie} #{type_voie} #{nom_voie}",
|
||||||
complement_adresse,
|
complement_adresse,
|
||||||
"#{code_postal} #{localite}"
|
"#{code_postal} #{localite}"
|
||||||
].map { |s| s.squeeze(' ') }.reject(&:blank?).join(', ')
|
].reject(&:blank?).join(', ').squeeze(' ')
|
||||||
end
|
end
|
||||||
|
|
||||||
def verify
|
def verify
|
||||||
|
|
|
@ -15,9 +15,26 @@ describe Etablissement do
|
||||||
it { expect(etablissement.inline_adresse).to eq '6 RUE green moon, IMMEUBLE BORA, 92270 BOIS COLOMBES' }
|
it { expect(etablissement.inline_adresse).to eq '6 RUE green moon, IMMEUBLE BORA, 92270 BOIS COLOMBES' }
|
||||||
|
|
||||||
context 'with missing complement adresse' do
|
context 'with missing complement adresse' do
|
||||||
|
let(:expected_adresse) { '6 RUE RAOUL NORDLING, 92270 BOIS COLOMBES' }
|
||||||
|
subject { etablissement.inline_adresse }
|
||||||
|
|
||||||
|
context 'when blank' do
|
||||||
let(:etablissement) { create(:etablissement, complement_adresse: '') }
|
let(:etablissement) { create(:etablissement, complement_adresse: '') }
|
||||||
|
|
||||||
it { expect(etablissement.inline_adresse).to eq '6 RUE RAOUL NORDLING, 92270 BOIS COLOMBES' }
|
it { is_expected.to eq expected_adresse }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when whitespace' do
|
||||||
|
let(:etablissement) { create(:etablissement, complement_adresse: ' ') }
|
||||||
|
|
||||||
|
it { is_expected.to eq expected_adresse }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when nil' do
|
||||||
|
let(:etablissement) { create(:etablissement, complement_adresse: nil) }
|
||||||
|
|
||||||
|
it { is_expected.to eq expected_adresse }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue