Merge pull request #10301 from demarches-simplifiees/more_work_on_city_address
Tech: simplifie le code address dans les champs commune
This commit is contained in:
commit
2de2d8af45
3 changed files with 2 additions and 20 deletions
|
@ -57,20 +57,11 @@ class Champs::CommuneChamp < Champs::TextChamp
|
|||
alias postal_code code_postal
|
||||
|
||||
def name
|
||||
if departement? && code?
|
||||
APIGeoService.commune_name(code_departement, code).presence || safe_to_s
|
||||
else
|
||||
safe_to_s
|
||||
end
|
||||
APIGeoService.safely_normalize_city_name(code_departement, code, safe_to_s)
|
||||
end
|
||||
|
||||
def to_s
|
||||
if departement? && code_postal? && code?
|
||||
name = APIGeoService.commune_name(code_departement, code)
|
||||
name.present? ? "#{name} (#{code_postal})" : safe_to_s
|
||||
else
|
||||
safe_to_s
|
||||
end
|
||||
code_postal? ? "#{name} (#{code_postal})" : name
|
||||
end
|
||||
|
||||
def code
|
||||
|
|
|
@ -126,9 +126,6 @@ class APIGeoService
|
|||
return fallback if department_code.nil? || city_code.nil?
|
||||
|
||||
commune_name(department_code, city_code) || fallback
|
||||
|
||||
rescue StandardError
|
||||
fallback
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -130,11 +130,5 @@ describe APIGeoService do
|
|||
|
||||
it { is_expected.to eq('Paris') }
|
||||
end
|
||||
|
||||
context 'with a wrong department' do
|
||||
let(:department_code) { 'wrong' }
|
||||
|
||||
it { is_expected.to eq('Paris') }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue