Merge pull request #10323 from tchak/fix-commune-with-blank-codes

fix(commune): no crash on blank codes
This commit is contained in:
Paul Chavard 2024-04-15 11:48:16 +00:00 committed by GitHub
commit d857ad1d0a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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