Merge pull request #10323 from tchak/fix-commune-with-blank-codes
fix(commune): no crash on blank codes
This commit is contained in:
commit
d857ad1d0a
2 changed files with 13 additions and 1 deletions
|
@ -123,7 +123,7 @@ class APIGeoService
|
||||||
end
|
end
|
||||||
|
|
||||||
def safely_normalize_city_name(department_code, city_code, fallback)
|
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
|
commune_name(department_code, city_code) || fallback
|
||||||
end
|
end
|
||||||
|
|
|
@ -130,5 +130,17 @@ describe APIGeoService do
|
||||||
|
|
||||||
it { is_expected.to eq('Paris') }
|
it { is_expected.to eq('Paris') }
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue