fix(commune): no crash on blank codes
This commit is contained in:
parent
cb2dd3dd3a
commit
ea47ba3747
2 changed files with 13 additions and 1 deletions
|
@ -123,7 +123,7 @@ class APIGeoService
|
|||
end
|
||||
|
||||
def safely_normalize_city_name(department_code, city_code, fallback)
|
||||
return fallback if department_code.nil? || city_code.nil?
|
||||
return fallback if department_code.blank? || city_code.blank?
|
||||
|
||||
commune_name(department_code, city_code) || fallback
|
||||
end
|
||||
|
|
|
@ -130,5 +130,17 @@ describe APIGeoService do
|
|||
|
||||
it { is_expected.to eq('Paris') }
|
||||
end
|
||||
|
||||
context 'with blank department' do
|
||||
let(:department_code) { '' }
|
||||
|
||||
it { is_expected.to eq('Paris') }
|
||||
end
|
||||
|
||||
context 'with blank city_code' do
|
||||
let(:city_code) { '' }
|
||||
|
||||
it { is_expected.to eq('Paris') }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue