Merge pull request #9241 from tchak/fix-ban-api-geo-difference
ETQ Opérateur, je souhaite mettre à jour les données de l'API GEO
This commit is contained in:
commit
c1b4a868aa
45 changed files with 121 additions and 57 deletions
|
@ -5,5 +5,11 @@ module Types::Champs
|
||||||
field :address, Types::AddressType, null: true
|
field :address, Types::AddressType, null: true
|
||||||
field :commune, Types::Champs::CommuneChampType::CommuneType, null: true
|
field :commune, Types::Champs::CommuneChampType::CommuneType, null: true
|
||||||
field :departement, Types::Champs::DepartementChampType::DepartementType, null: true
|
field :departement, Types::Champs::DepartementChampType::DepartementType, null: true
|
||||||
|
|
||||||
|
def address
|
||||||
|
if object.full_address?
|
||||||
|
object.address.merge('city_code' => object.commune.fetch(:code))
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -69,10 +69,6 @@ class Champs::AddressChamp < Champs::TextChamp
|
||||||
APIGeoService.departement_name(address.fetch('department_code'))
|
APIGeoService.departement_name(address.fetch('department_code'))
|
||||||
end
|
end
|
||||||
|
|
||||||
def commune_name
|
|
||||||
APIGeoService.commune_name(address.fetch('department_code'), address.fetch('city_code'))
|
|
||||||
end
|
|
||||||
|
|
||||||
def departement
|
def departement
|
||||||
if full_address?
|
if full_address?
|
||||||
{ code: address.fetch('department_code'), name: departement_name }
|
{ code: address.fetch('department_code'), name: departement_name }
|
||||||
|
@ -81,7 +77,30 @@ class Champs::AddressChamp < Champs::TextChamp
|
||||||
|
|
||||||
def commune
|
def commune
|
||||||
if full_address?
|
if full_address?
|
||||||
{ code: address.fetch('city_code'), name: commune_name, postal_code: address.fetch('postal_code') }
|
department_code = address.fetch('department_code')
|
||||||
|
city_code = address.fetch('city_code')
|
||||||
|
city_name = address.fetch('city_name')
|
||||||
|
postal_code = address.fetch('postal_code')
|
||||||
|
|
||||||
|
commune_name = APIGeoService.commune_name(department_code, city_code)
|
||||||
|
commune_code = APIGeoService.commune_code(department_code, city_name)
|
||||||
|
|
||||||
|
if commune_name.present?
|
||||||
|
{
|
||||||
|
code: city_code,
|
||||||
|
name: commune_name
|
||||||
|
}
|
||||||
|
elsif commune_code.present?
|
||||||
|
{
|
||||||
|
code: commune_code,
|
||||||
|
name: city_name
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
code: city_code,
|
||||||
|
name: city_name
|
||||||
|
}
|
||||||
|
end.merge(postal_code:)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -60,17 +60,18 @@ class Champs::CommuneChamp < Champs::TextChamp
|
||||||
|
|
||||||
def name
|
def name
|
||||||
if code?
|
if code?
|
||||||
APIGeoService.commune_name(code_departement, code)
|
APIGeoService.commune_name(code_departement, code).presence || safe_to_s
|
||||||
else
|
else
|
||||||
value.present? ? value.to_s : ''
|
safe_to_s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
if code?
|
if code?
|
||||||
"#{APIGeoService.commune_name(code_departement, code)} (#{code_postal})"
|
name = APIGeoService.commune_name(code_departement, code)
|
||||||
|
name.present? ? "#{name} (#{code_postal})" : safe_to_s
|
||||||
else
|
else
|
||||||
value.present? ? value.to_s : ''
|
safe_to_s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -111,6 +112,10 @@ class Champs::CommuneChamp < Champs::TextChamp
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def safe_to_s
|
||||||
|
value.present? ? value.to_s : ''
|
||||||
|
end
|
||||||
|
|
||||||
def on_code_postal_change
|
def on_code_postal_change
|
||||||
if code_postal_changed?
|
if code_postal_changed?
|
||||||
if communes.one?
|
if communes.one?
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
- if champ.to_s.present?
|
- if champ.to_s.present?
|
||||||
%p= format_text_value(champ.to_s)
|
= format_text_value(champ.to_s)
|
||||||
- if champ.data.present?
|
- if champ.full_address?
|
||||||
%p
|
|
||||||
Code INSEE :
|
Code INSEE :
|
||||||
= champ.data['city_code']
|
= champ.commune&.fetch(:code)
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1 +1 @@
|
||||||
[{"name":"CC de la Marche Berrichonne","code":"200007052"},{"name":"CC du Val de Bouzanne","code":"200018521"},{"name":"CC Marche Occitane - Val d’Anglin","code":"200035137"},{"name":"CC du Châtillonnais en Berry","code":"200035848"},{"name":"CC Ecueillé-Valençay","code":"200040558"},{"name":"CC Eguzon - Argenton - Vallée de la Creuse","code":"200068872"},{"name":"CC Champagne Boischauts","code":"200068880"},{"name":"CC Chabris - Pays de Bazelle","code":"243600202"},{"name":"CC du Pays d’Issoudun","code":"243600236"},{"name":"CC de la Région de Levroux","code":"243600293"},{"name":"CC Val de l’Indre - Brenne","code":"243600301"},{"name":"CC Brenne - Val de Creuse","code":"243600319"},{"name":"CA Châteauroux Métropole","code":"243600327"},{"name":"CC Coeur de Brenne","code":"243600343"},{"name":"CC de la Châtre et Sainte-Sévère","code":"243600350"}]
|
[{"name":"CC de la Marche Berrichonne","code":"200007052"},{"name":"CC du Val de Bouzanne","code":"200018521"},{"name":"CC Marche Occitane - Val d’Anglin","code":"200035137"},{"name":"CC du Châtillonnais en Berry","code":"200035848"},{"name":"CC Ecueillé-Valençay","code":"200040558"},{"name":"CC Eguzon - Argenton - Vallée de la Creuse","code":"200068872"},{"name":"CC Champagne Boischauts","code":"200068880"},{"name":"CC Chabris - Pays de Bazelle","code":"243600202"},{"name":"CC du Pays d’Issoudun","code":"243600236"},{"name":"CC Levroux Boischaut Champagne","code":"243600293"},{"name":"CC Val de l’Indre - Brenne","code":"243600301"},{"name":"CC Brenne - Val de Creuse","code":"243600319"},{"name":"CA Châteauroux Métropole","code":"243600327"},{"name":"CC Coeur de Brenne","code":"243600343"},{"name":"CC de la Châtre et Sainte-Sévère","code":"243600350"}]
|
|
@ -1 +1 @@
|
||||||
[{"name":"CC du Val d Amboise","code":"200043065"},{"name":"CC Chinon, Vienne et Loire","code":"200043081"},{"name":"CC Loches Sud Touraine","code":"200071587"},{"name":"CC Touraine Vallée de l’Indre","code":"200072650"},{"name":"CC Touraine Val de Vienne","code":"200072668"},{"name":"CC Touraine Ouest Val de Loire","code":"200072981"},{"name":"CC Touraine-Est Vallées","code":"200073161"},{"name":"CC de Gâtine et Choisilles - Pays de Racan","code":"200073237"},{"name":"CC du Castelrenaudais","code":"243700499"},{"name":"Tours Métropole Val de Loire","code":"243700754"},{"name":"CC de Bléré Val de Cher","code":"243700820"}]
|
[{"name":"CC du Val d Amboise","code":"200043065"},{"name":"CC Chinon, Vienne et Loire","code":"200043081"},{"name":"CC Loches Sud Touraine","code":"200071587"},{"name":"CC Touraine Vallée de l’Indre","code":"200072650"},{"name":"CC Touraine Val de Vienne","code":"200072668"},{"name":"CC Touraine Ouest Val de Loire","code":"200072981"},{"name":"CC Touraine-Est Vallées","code":"200073161"},{"name":"CC de Gâtine-Racan","code":"200073237"},{"name":"CC du Castelrenaudais","code":"243700499"},{"name":"Tours Métropole Val de Loire","code":"243700754"},{"name":"CC Autour de Chenonceaux Bléré-Val de Cher","code":"243700820"}]
|
|
@ -1 +1 @@
|
||||||
[{"name":"CC Le Grésivaudan","code":"200018166"},{"name":"CC du Trièves","code":"200030658"},{"name":"CC Coeur de Chartreuse","code":"200040111"},{"name":"CC de la Matheysine","code":"200040657"},{"name":"Grenoble-Alpes-Métropole","code":"200040715"},{"name":"CC Bièvre Isère","code":"200059392"},{"name":"CC Les Balcons du Dauphiné","code":"200068542"},{"name":"CC Les Vals du Dauphiné","code":"200068567"},{"name":"CC Saint-Marcellin Vercors Isère Communauté","code":"200070431"},{"name":"CA Vienne Condrieu","code":"200077014"},{"name":"CC Entre Bièvre et Rhône","code":"200085751"},{"name":"CA Porte de l’Isère (CAPI)","code":"243800604"},{"name":"CC de l’Oisans","code":"243800745"},{"name":"CC Lyon-Saint-Exupéry en Dauphiné","code":"243800935"},{"name":"CA du Pays Voironnais","code":"243800984"},{"name":"CC du Massif du Vercors","code":"243801024"},{"name":"CC de Bièvre Est","code":"243801073"},{"name":"CC COLLines Isère Nord Communauté","code":"243801255"}]
|
[{"name":"CC Le Grésivaudan","code":"200018166"},{"name":"CC du Trièves","code":"200030658"},{"name":"CC Coeur de Chartreuse","code":"200040111"},{"name":"CC de la Matheysine","code":"200040657"},{"name":"Grenoble-Alpes-Métropole","code":"200040715"},{"name":"CC Bièvre Isère","code":"200059392"},{"name":"CC Les Balcons du Dauphiné","code":"200068542"},{"name":"CC Les Vals du Dauphiné","code":"200068567"},{"name":"CC Saint-Marcellin Vercors Isère Communauté","code":"200070431"},{"name":"CA Vienne Condrieu","code":"200077014"},{"name":"CC Entre Bièvre et Rhône","code":"200085751"},{"name":"CA Porte de l’Isère (CAPI)","code":"243800604"},{"name":"CC de l’Oisans","code":"243800745"},{"name":"CC Lyon-Saint-Exupéry en Dauphiné","code":"243800935"},{"name":"CA du Pays Voironnais","code":"243800984"},{"name":"CC du Massif du Vercors","code":"243801024"},{"name":"CC de Bièvre Est","code":"243801073"},{"name":"CC Collines Isère Nord Communauté","code":"243801255"}]
|
|
@ -1 +1 @@
|
||||||
[{"name":"CC du Pays de Pontchâteau St-Gildas-des-Bois","code":"200000438"},{"name":"CA Pornic Agglo Pays de Retz","code":"200067346"},{"name":"CA Clisson Sèvre et Maine Agglo","code":"200067635"},{"name":"CC Sèvre et Loire","code":"200067866"},{"name":"CC Sud Retz Atlantique","code":"200071546"},{"name":"CC Châteaubriant-Derval","code":"200072726"},{"name":"CC Estuaire et Sillon","code":"200072734"},{"name":"CA Redon Agglomération","code":"243500741"},{"name":"Nantes Métropole","code":"244400404"},{"name":"CC Grand Lieu Communauté","code":"244400438"},{"name":"CC de la Région de Blain","code":"244400453"},{"name":"CC d’Erdre et Gesvres","code":"244400503"},{"name":"CC de Nozay","code":"244400537"},{"name":"CC du Pays d’Ancenis","code":"244400552"},{"name":"CC du Sud Estuaire","code":"244400586"},{"name":"CA de la Presqu’île de Guérande Atlantique (CAP ATLANTIQUE)","code":"244400610"},{"name":"CA de la Région Nazairienne et de l’Estuaire (CARENE)","code":"244400644"}]
|
[{"name":"CC du Pays de Pontchâteau St-Gildas-des-Bois","code":"200000438"},{"name":"CA Pornic Agglo Pays de Retz","code":"200067346"},{"name":"CA Clisson Sèvre et Maine Agglo","code":"200067635"},{"name":"CC Sèvre et Loire","code":"200067866"},{"name":"CC Sud Retz Atlantique","code":"200071546"},{"name":"CC Châteaubriant-Derval","code":"200072726"},{"name":"CC Estuaire et Sillon","code":"200072734"},{"name":"CA Redon Agglomération","code":"243500741"},{"name":"Nantes Métropole","code":"244400404"},{"name":"CC Grand Lieu Communauté","code":"244400438"},{"name":"CC Pays de Blain communauté","code":"244400453"},{"name":"CC d’Erdre et Gesvres","code":"244400503"},{"name":"CC de Nozay","code":"244400537"},{"name":"CC du Pays d’Ancenis","code":"244400552"},{"name":"CC du Sud Estuaire","code":"244400586"},{"name":"CA de la Presqu’île de Guérande Atlantique (CAP ATLANTIQUE)","code":"244400610"},{"name":"CA de la Région Nazairienne et de l’Estuaire (CARENE)","code":"244400644"}]
|
|
@ -1 +1 @@
|
||||||
[{"name":"CC des Coëvrons","code":"200033298"},{"name":"CC du Mont des Avaloirs","code":"200042182"},{"name":"CC du Pays de Craon","code":"200048551"},{"name":"CC Mayenne Communauté","code":"200055887"},{"name":"CA Laval Agglomération","code":"200083392"},{"name":"CC du Pays de Meslay-Grez","code":"245300223"},{"name":"CC de l’Ernée","code":"245300355"},{"name":"CC du Bocage Mayennais","code":"245300389"},{"name":"CC du Pays de Château-Gontier","code":"245300447"},{"name":"CC Communauté de communes du Pays Sabolien","code":"247200090"}]
|
[{"name":"CC des Coëvrons","code":"200033298"},{"name":"CC du Mont des Avaloirs","code":"200042182"},{"name":"CC du Pays de Craon","code":"200048551"},{"name":"CC Mayenne Communauté","code":"200055887"},{"name":"CA Laval Agglomération","code":"200083392"},{"name":"CC du Pays de Meslay-Grez","code":"245300223"},{"name":"CC de l’Ernée","code":"245300355"},{"name":"CC du Bocage Mayennais","code":"245300389"},{"name":"CC du Pays de Château-Gontier","code":"245300447"},{"name":"CC du Pays Sabolien","code":"247200090"}]
|
|
@ -1 +1 @@
|
||||||
[{"name":"CC Arc Sud Bretagne","code":"200027027"},{"name":"CA Lorient Agglomération","code":"200042174"},{"name":"CC Auray Quiberon Terre Atlantique","code":"200043123"},{"name":"CC Ploërmel Communauté","code":"200066777"},{"name":"CC de l’Oust à Brocéliande","code":"200066785"},{"name":"CA Golfe du Morbihan - Vannes Agglomération","code":"200067932"},{"name":"CC Baud Communauté","code":"200096675"},{"name":"CC Centre Morbihan Communauté","code":"200096683"},{"name":"CA Redon Agglomération","code":"243500741"},{"name":"CA de la Presqu’île de Guérande Atlantique (CAP ATLANTIQUE)","code":"244400610"},{"name":"CC de Blavet Bellevue Océan","code":"245600440"},{"name":"CC de Belle Ile en Mer","code":"245600465"},{"name":"CC Questembert Communauté","code":"245614383"},{"name":"CC Roi Morvan Communauté","code":"245614417"},{"name":"CC Pontivy Communauté","code":"245614433"}]
|
[{"name":"CC Arc Sud Bretagne","code":"200027027"},{"name":"CA Lorient Agglomération","code":"200042174"},{"name":"CC Auray Quiberon Terre Atlantique","code":"200043123"},{"name":"CC Ploërmel Communauté","code":"200066777"},{"name":"CC de l’Oust à Brocéliande","code":"200066785"},{"name":"CA Golfe du Morbihan - Vannes Agglomération","code":"200067932"},{"name":"CC Baud Communauté","code":"200096675"},{"name":"CC Centre Morbihan Communauté","code":"200096683"},{"name":"CA Redon Agglomération","code":"243500741"},{"name":"CA de la Presqu’île de Guérande Atlantique (CAP ATLANTIQUE)","code":"244400610"},{"name":"CC Blavet Bellevue Océan","code":"245600440"},{"name":"CC de Belle Ile en Mer","code":"245600465"},{"name":"CC Questembert Communauté","code":"245614383"},{"name":"CC Roi Morvan Communauté","code":"245614417"},{"name":"CC Pontivy Communauté","code":"245614433"}]
|
|
@ -1 +1 @@
|
||||||
[{"name":"CC du Ried de Marckolsheim","code":"200030526"},{"name":"CC de Thann-Cernay","code":"200036465"},{"name":"CA Mulhouse Alsace Agglomération","code":"200066009"},{"name":"CC Pays Rhin - Brisach","code":"200066025"},{"name":"CC Sud Alsace Largue","code":"200066033"},{"name":"CC Sundgau","code":"200066041"},{"name":"CA Saint-Louis Agglomération","code":"200066058"},{"name":"CC de la Vallée de Saint-Amarin","code":"246800205"},{"name":"CC du Val d’Argent","code":"246800395"},{"name":"CC du Centre du Haut-Rhin","code":"246800445"},{"name":"CC du Pays de Rouffach, Vignobles et Châteaux","code":"246800494"},{"name":"CC de la Vallée de Kaysersberg","code":"246800551"},{"name":"CC de la Région de Guebwiller","code":"246800569"},{"name":"CC du Pays de Ribeauvillé","code":"246800577"},{"name":"CC de la Vallée de Munster","code":"246800585"},{"name":"CC de la Vallée de la Doller et du Soultzbach","code":"246800676"},{"name":"CA Colmar Agglomération","code":"246800726"}]
|
[{"name":"CC du Ried de Marckolsheim","code":"200030526"},{"name":"CC de Thann-Cernay","code":"200036465"},{"name":"CA Mulhouse Alsace Agglomération","code":"200066009"},{"name":"CC Alsace Rhin Brisach","code":"200066025"},{"name":"CC Sud Alsace Largue","code":"200066033"},{"name":"CC Sundgau","code":"200066041"},{"name":"CA Saint-Louis Agglomération","code":"200066058"},{"name":"CC de la Vallée de Saint-Amarin","code":"246800205"},{"name":"CC du Val d’Argent","code":"246800395"},{"name":"CC du Centre du Haut-Rhin","code":"246800445"},{"name":"CC du Pays de Rouffach, Vignobles et Châteaux","code":"246800494"},{"name":"CC de la Vallée de Kaysersberg","code":"246800551"},{"name":"CC de la Région de Guebwiller","code":"246800569"},{"name":"CC du Pays de Ribeauvillé","code":"246800577"},{"name":"CC de la Vallée de Munster","code":"246800585"},{"name":"CC de la Vallée de la Doller et du Soultzbach","code":"246800676"},{"name":"CA Colmar Agglomération","code":"246800726"}]
|
|
@ -1 +1 @@
|
||||||
[{"name":"CC Loué - Brûlon - Noyen","code":"200040475"},{"name":"CC Maine Coeur de Sarthe","code":"200068963"},{"name":"CC Loir-Lucé-Bercé","code":"200070373"},{"name":"CC Maine Saosnois","code":"200072676"},{"name":"CC Le Gesnois Bilurien","code":"200072684"},{"name":"CC des Vallées de la Braye et de l’Anille","code":"200072692"},{"name":"CC Haute Sarthe Alpes Mancelles","code":"200072700"},{"name":"CC de la Champagne Conlinoise et du Pays de Sillé","code":"200072718"},{"name":"CC Sud Sarthe","code":"200073112"},{"name":"CU d’Alençon","code":"246100663"},{"name":"CC Communauté de communes du Pays Sabolien","code":"247200090"},{"name":"CU Le Mans Métropole","code":"247200132"},{"name":"CC du Pays Fléchois","code":"247200348"},{"name":"CC du Sud Est Manceau","code":"247200421"},{"name":"CC Orée de Bercé - Belinois","code":"247200447"},{"name":"CC du Val de Sarthe","code":"247200629"},{"name":"CC du Pays de l’Huisne Sarthoise","code":"247200686"}]
|
[{"name":"CC LBN Communauté","code":"200040475"},{"name":"CC Maine Coeur de Sarthe","code":"200068963"},{"name":"CC Loir-Lucé-Bercé","code":"200070373"},{"name":"CC Maine Saosnois","code":"200072676"},{"name":"CC Le Gesnois Bilurien","code":"200072684"},{"name":"CC des Vallées de la Braye et de l’Anille","code":"200072692"},{"name":"CC Haute Sarthe Alpes Mancelles","code":"200072700"},{"name":"CC de la Champagne Conlinoise et du Pays de Sillé","code":"200072718"},{"name":"CC Sud Sarthe","code":"200073112"},{"name":"CU d’Alençon","code":"246100663"},{"name":"CC du Pays Sabolien","code":"247200090"},{"name":"CU Le Mans Métropole","code":"247200132"},{"name":"CC du Pays Fléchois","code":"247200348"},{"name":"CC du Sud Est Manceau","code":"247200421"},{"name":"CC Orée de Bercé - Belinois","code":"247200447"},{"name":"CC du Val de Sarthe","code":"247200629"},{"name":"CC du Pays de l’Huisne Sarthoise","code":"247200686"}]
|
|
@ -1 +1 @@
|
||||||
[{"name":"CA Caux Seine Agglo","code":"200010700"},{"name":"Métropole Rouen Normandie","code":"200023414"},{"name":"CC Roumois Seine","code":"200066405"},{"name":"CC Terroir de Caux","code":"200068534"},{"name":"CC interrégionale Aumale - Blangy-sur-Bresle","code":"200069722"},{"name":"CC des 4 rivières","code":"200069730"},{"name":"CA Fécamp Caux Littoral Agglomération","code":"200069821"},{"name":"CC de la Côte d’Albâtre","code":"200069839"},{"name":"CC Plateau de Caux-Doudeville-Yerville","code":"200069847"},{"name":"CC Communauté Bray-Eawy","code":"200070068"},{"name":"CC inter-Caux-Vexin","code":"200070449"},{"name":"CU Le Havre Seine Métropole","code":"200084952"},{"name":"CC Campagne-de-Caux","code":"247600505"},{"name":"CC des Villes Soeurs","code":"247600588"},{"name":"CC de Londinières","code":"247600604"},{"name":"CC Yvetot Normandie","code":"247600620"},{"name":"CC Caux - Austreberthe","code":"247600646"},{"name":"CC Falaises du Talou","code":"247600729"},{"name":"CA de la Région Dieppoise","code":"247600786"}]
|
[{"name":"CA Caux Seine Agglo","code":"200010700"},{"name":"Métropole Rouen Normandie","code":"200023414"},{"name":"CC Roumois Seine","code":"200066405"},{"name":"CC Terroir de Caux","code":"200068534"},{"name":"CC interrégionale Aumale - Blangy-sur-Bresle","code":"200069722"},{"name":"CC des 4 rivières","code":"200069730"},{"name":"CA Fécamp Caux Littoral Agglomération","code":"200069821"},{"name":"CC de la Côte d’Albâtre","code":"200069839"},{"name":"CC Plateau de Caux","code":"200069847"},{"name":"CC Communauté Bray-Eawy","code":"200070068"},{"name":"CC inter-Caux-Vexin","code":"200070449"},{"name":"CU Le Havre Seine Métropole","code":"200084952"},{"name":"CC Campagne-de-Caux","code":"247600505"},{"name":"CC des Villes Soeurs","code":"247600588"},{"name":"CC de Londinières","code":"247600604"},{"name":"CC Yvetot Normandie","code":"247600620"},{"name":"CC Caux - Austreberthe","code":"247600646"},{"name":"CC Falaises du Talou","code":"247600729"},{"name":"CA de la Région Dieppoise","code":"247600786"}]
|
|
@ -1 +1 @@
|
||||||
[{"name":"CC du Pays de Serres en Quercy","code":"200040418"},{"name":"CC Terres des Confluences","code":"200066322"},{"name":"CC Grand Sud Tarn et Garonne","code":"200066652"},{"name":"CC Quercy Vert-Aveyron","code":"200066884"},{"name":"CC Coteaux et Plaines du Pays Lafrançaisain","code":"200067122"},{"name":"CC des Deux Rives","code":"248200016"},{"name":"CC du Quercy Caussadais","code":"248200057"},{"name":"CC de la Lomagne Tarn-et-Garonnaise","code":"248200065"},{"name":"CA Grand Montauban","code":"248200099"},{"name":"CC du Quercy Rouergue et des Gorges de l’Aveyron","code":"248200107"}]
|
[{"name":"CC du Pays de Serres en Quercy","code":"200040418"},{"name":"CC Terres des Confluences","code":"200066322"},{"name":"CC Grand Sud Tarn et Garonne","code":"200066652"},{"name":"CC Quercy Vert-Aveyron","code":"200066884"},{"name":"CC du Pays de Lafrançaise","code":"200067122"},{"name":"CC des Deux Rives","code":"248200016"},{"name":"CC du Quercy Caussadais","code":"248200057"},{"name":"CC de la Lomagne Tarn-et-Garonnaise","code":"248200065"},{"name":"CA Grand Montauban","code":"248200099"},{"name":"CC du Quercy Rouergue et des Gorges de l’Aveyron","code":"248200107"}]
|
|
@ -1 +1 @@
|
||||||
[{"name":"CC Rhône Lez Provence","code":"200000628"},{"name":"CC Ventoux Sud","code":"200035723"},{"name":"CA Luberon Monts de Vaucluse","code":"200040442"},{"name":"CC Pays d’Apt-Luberon","code":"200040624"},{"name":"CC Enclave des Papes-Pays de Grignan","code":"200040681"},{"name":"Métropole d’Aix-Marseille-Provence","code":"200054807"},{"name":"CA Ventoux-Comtat-Venaissin (COVE)","code":"248400053"},{"name":"CC Aygues-Ouvèze en Provence (CCAOP)","code":"248400160"},{"name":"CC du Pays Réuni d’Orange","code":"248400236"},{"name":"CA du Grand Avignon (COGA)","code":"248400251"},{"name":"CC Territoriale Sud-Luberon","code":"248400285"},{"name":"CA des Sorgues du Comtat","code":"248400293"},{"name":"CC du Pays des Sorgues et des Monts de Vaucluse","code":"248400319"},{"name":"CC Vaison Ventoux","code":"248400335"}]
|
[{"name":"CC Rhône Lez Provence","code":"200000628"},{"name":"CC Ventoux Sud","code":"200035723"},{"name":"CA Luberon Monts de Vaucluse","code":"200040442"},{"name":"CC Pays d’Apt-Luberon","code":"200040624"},{"name":"CC Enclave des Papes-Pays de Grignan","code":"200040681"},{"name":"Métropole d’Aix-Marseille-Provence","code":"200054807"},{"name":"CA Ventoux-Comtat-Venaissin (COVE)","code":"248400053"},{"name":"CC Aygues-Ouvèze en Provence (CCAOP)","code":"248400160"},{"name":"CC Pays d’Orange en Provence","code":"248400236"},{"name":"CA du Grand Avignon (COGA)","code":"248400251"},{"name":"CC Territoriale Sud-Luberon","code":"248400285"},{"name":"CA des Sorgues du Comtat","code":"248400293"},{"name":"CC du Pays des Sorgues et des Monts de Vaucluse","code":"248400319"},{"name":"CC Vaison Ventoux","code":"248400335"}]
|
|
@ -11,10 +11,45 @@ describe Champs::AddressChamp do
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with value and data" do
|
context "with value and data" do
|
||||||
let(:value) { 'Paris' }
|
let(:value) { '33 Rue Rébeval 75019 Paris' }
|
||||||
let(:data) { { label: 'Paris' } }
|
let(:data) do
|
||||||
|
{
|
||||||
|
"type" => "housenumber",
|
||||||
|
"label" => "33 Rue Rébeval 75019 Paris",
|
||||||
|
"city_code" => "75119",
|
||||||
|
"city_name" => "Paris",
|
||||||
|
"postal_code" => "75019",
|
||||||
|
"region_code" => "11",
|
||||||
|
"region_name" => "Île-de-France",
|
||||||
|
"street_name" => "Rue Rébeval",
|
||||||
|
"street_number" => "33",
|
||||||
|
"street_address" => "33 Rue Rébeval",
|
||||||
|
"department_code" => "75",
|
||||||
|
"department_name" => "Paris"
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
it { expect(champ.address_label).to eq('Paris') }
|
it { expect(champ.address_label).to eq('33 Rue Rébeval 75019 Paris') }
|
||||||
it { expect(champ.full_address?).to be_truthy }
|
it { expect(champ.full_address?).to be_truthy }
|
||||||
|
it { expect(champ.commune).to eq({ name: 'Paris 19e Arrondissement', code: '75119', postal_code: '75019' }) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with wrong code INSEE" do
|
||||||
|
let(:value) { 'Rue du Bois Charles 27700 Les Trois Lacs' }
|
||||||
|
let(:data) do
|
||||||
|
{
|
||||||
|
"type" => "housenumber",
|
||||||
|
"label" => "Rue du Bois Charles 27700 Les Trois Lacs",
|
||||||
|
"city_code" => "27058",
|
||||||
|
"city_name" => "Les Trois Lacs",
|
||||||
|
"postal_code" => "27700",
|
||||||
|
"department_code" => "27",
|
||||||
|
"department_name" => "Eure"
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
it { expect(champ.address_label).to eq('Rue du Bois Charles 27700 Les Trois Lacs') }
|
||||||
|
it { expect(champ.full_address?).to be_truthy }
|
||||||
|
it { expect(champ.commune).to eq({ name: 'Les Trois Lacs', code: '27676', postal_code: '27700' }) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -38,7 +38,7 @@ describe APIGeoService do
|
||||||
|
|
||||||
describe 'communes' do
|
describe 'communes' do
|
||||||
it 'return sorted results' do
|
it 'return sorted results' do
|
||||||
expect(APIGeoService.communes('01').size).to eq(399)
|
expect(APIGeoService.communes('01').size).to eq(398)
|
||||||
expect(APIGeoService.communes('01').first).to eq(code: '01004', name: 'Ambérieu-en-Bugey', postal_code: '01500', departement_code: '01', epci_code: '240100883')
|
expect(APIGeoService.communes('01').first).to eq(code: '01004', name: 'Ambérieu-en-Bugey', postal_code: '01500', departement_code: '01', epci_code: '240100883')
|
||||||
expect(APIGeoService.communes('01').last).to eq(code: '01457', name: 'Vonnas', postal_code: '01540', departement_code: '01', epci_code: '200070555')
|
expect(APIGeoService.communes('01').last).to eq(code: '01457', name: 'Vonnas', postal_code: '01540', departement_code: '01', epci_code: '200070555')
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue