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}",
|
||||
complement_adresse,
|
||||
"#{code_postal} #{localite}"
|
||||
].map { |s| s.squeeze(' ') }.reject(&:blank?).join(', ')
|
||||
].reject(&:blank?).join(', ').squeeze(' ')
|
||||
end
|
||||
|
||||
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' }
|
||||
|
||||
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: '') }
|
||||
|
||||
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
|
||||
|
||||
|
|
Loading…
Reference in a new issue