fix(commune): no crash on blank codes

This commit is contained in:
Paul Chavard 2024-04-15 11:01:15 +02:00
parent cb2dd3dd3a
commit ea47ba3747
2 changed files with 13 additions and 1 deletions

View file

@ -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

View file

@ -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