Remove legacy carto routes
This commit is contained in:
parent
63a903204f
commit
b5a3fc76fb
4 changed files with 0 additions and 117 deletions
|
@ -129,25 +129,6 @@ module NewGestionnaire
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def position
|
|
||||||
etablissement = dossier.etablissement
|
|
||||||
|
|
||||||
if etablissement.present?
|
|
||||||
point = Carto::Geocodeur.convert_adresse_to_point(etablissement.geo_adresse)
|
|
||||||
end
|
|
||||||
|
|
||||||
lon = "2.428462"
|
|
||||||
lat = "46.538192"
|
|
||||||
zoom = "13"
|
|
||||||
|
|
||||||
if point.present?
|
|
||||||
lon = point.x.to_s
|
|
||||||
lat = point.y.to_s
|
|
||||||
end
|
|
||||||
|
|
||||||
render json: { lon: lon, lat: lat, zoom: zoom, dossier_id: params[:dossier_id] }
|
|
||||||
end
|
|
||||||
|
|
||||||
def create_avis
|
def create_avis
|
||||||
@avis = Avis.new(avis_params.merge(claimant: current_gestionnaire, dossier: dossier))
|
@avis = Avis.new(avis_params.merge(claimant: current_gestionnaire, dossier: dossier))
|
||||||
if @avis.save
|
if @avis.save
|
||||||
|
|
|
@ -28,36 +28,6 @@ class Users::CarteController < UsersController
|
||||||
redirect_to brouillon_dossier_path(dossier)
|
redirect_to brouillon_dossier_path(dossier)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_position
|
|
||||||
begin
|
|
||||||
etablissement = current_user_dossier.etablissement
|
|
||||||
rescue ActiveRecord::RecordNotFound
|
|
||||||
etablissement = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
if etablissement.present?
|
|
||||||
point = Carto::Geocodeur.convert_adresse_to_point(etablissement.geo_adresse)
|
|
||||||
end
|
|
||||||
|
|
||||||
lon = '2.428462'
|
|
||||||
lat = '46.538192'
|
|
||||||
zoom = '13'
|
|
||||||
|
|
||||||
if point.present?
|
|
||||||
lon = point.x.to_s
|
|
||||||
lat = point.y.to_s
|
|
||||||
end
|
|
||||||
|
|
||||||
render json: { lon: lon, lat: lat, zoom: zoom, dossier_id: params[:dossier_id] }
|
|
||||||
end
|
|
||||||
|
|
||||||
def get_qp
|
|
||||||
render json: { quartier_prioritaires: ModuleApiCartoService.generate_qp(JSON.parse(params[:coordinates])) }
|
|
||||||
end
|
|
||||||
|
|
||||||
def get_cadastre
|
|
||||||
render json: { cadastres: ModuleApiCartoService.generate_cadastre(JSON.parse(params[:coordinates])) }
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.route_authorization
|
def self.route_authorization
|
||||||
{
|
{
|
||||||
|
|
|
@ -152,10 +152,6 @@ Rails.application.routes.draw do
|
||||||
resources :dossiers do
|
resources :dossiers do
|
||||||
get '/add_siret' => 'dossiers/add_siret#show'
|
get '/add_siret' => 'dossiers/add_siret#show'
|
||||||
|
|
||||||
get '/carte/position' => 'carte#get_position'
|
|
||||||
post '/carte/qp' => 'carte#get_qp'
|
|
||||||
post '/carte/cadastre' => 'carte#get_cadastre'
|
|
||||||
|
|
||||||
get '/carte' => 'carte#show'
|
get '/carte' => 'carte#show'
|
||||||
post '/carte' => 'carte#save'
|
post '/carte' => 'carte#save'
|
||||||
|
|
||||||
|
@ -333,9 +329,6 @@ Rails.application.routes.draw do
|
||||||
post 'repasser-en-construction' => 'dossiers#repasser_en_construction'
|
post 'repasser-en-construction' => 'dossiers#repasser_en_construction'
|
||||||
post 'terminer'
|
post 'terminer'
|
||||||
post 'send-to-instructeurs' => 'dossiers#send_to_instructeurs'
|
post 'send-to-instructeurs' => 'dossiers#send_to_instructeurs'
|
||||||
scope :carte do
|
|
||||||
get 'position'
|
|
||||||
end
|
|
||||||
post 'avis' => 'dossiers#create_avis'
|
post 'avis' => 'dossiers#create_avis'
|
||||||
get 'print' => 'dossiers#print'
|
get 'print' => 'dossiers#print'
|
||||||
end
|
end
|
||||||
|
|
|
@ -210,68 +210,7 @@ shared_examples 'carte_controller_spec' do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#get_position' do
|
|
||||||
context 'when etablissement is nil' do
|
|
||||||
before do
|
|
||||||
dossier.update etablissement: nil
|
|
||||||
|
|
||||||
stub_request(:get, /http:\/\/api-adresse[.]data[.]gouv[.]fr\/search[?]limit=1&q=/)
|
|
||||||
.to_return(status: 200, body: '{"query": "babouba", "version": "draft", "licence": "ODbL 1.0", "features": [], "type": "FeatureCollection", "attribution": "BAN"}', headers: {})
|
|
||||||
get :get_position, params: { dossier_id: dossier.id }
|
|
||||||
end
|
|
||||||
|
|
||||||
subject { JSON.parse(response.body) }
|
|
||||||
|
|
||||||
it 'on enregistre des coordonnées lat et lon avec les valeurs par defaut' do
|
|
||||||
expect(subject['lat']).to eq('46.538192')
|
|
||||||
expect(subject['lon']).to eq('2.428462')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'Geocodeur renvoie les positions par defaut' do
|
|
||||||
let(:etablissement) { create(:etablissement, adresse: bad_adresse, numero_voie: 'dzj', type_voie: 'fzjfk', nom_voie: 'hdidjkz', complement_adresse: 'fjef', code_postal: 'fjeiefk', localite: 'zjfkfz') }
|
|
||||||
let(:dossier) { create(:dossier, etablissement: etablissement) }
|
|
||||||
|
|
||||||
before do
|
|
||||||
stub_request(:get, /http:\/\/api-adresse[.]data[.]gouv[.]fr\/search[?]limit=1&q=/)
|
|
||||||
.to_return(status: 200, body: '{"query": "babouba", "version": "draft", "licence": "ODbL 1.0", "features": [], "type": "FeatureCollection", "attribution": "BAN"}', headers: {})
|
|
||||||
get :get_position, params: { dossier_id: dossier.id }
|
|
||||||
end
|
|
||||||
|
|
||||||
subject { JSON.parse(response.body) }
|
|
||||||
|
|
||||||
it 'on enregistre des coordonnées lat et lon avec les valeurs par defaut' do
|
|
||||||
expect(subject['lat']).to eq('46.538192')
|
|
||||||
expect(subject['lon']).to eq('2.428462')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'retour d\'un fichier JSON avec 3 attributs' do
|
|
||||||
before do
|
|
||||||
stub_request(:get, "http://api-adresse.data.gouv.fr/search?limit=1&q=#{adresse}")
|
|
||||||
.to_return(status: 200, body: '{"query": "50 avenue des champs u00e9lysu00e9es Paris 75008", "version": "draft", "licence": "ODbL 1.0", "features": [{"geometry": {"coordinates": [2.306888, 48.870374], "type": "Point"}, "type": "Feature", "properties": {"city": "Paris", "label": "50 Avenue des Champs u00c9lysu00e9es 75008 Paris", "housenumber": "50", "id": "ADRNIVX_0000000270748251", "postcode": "75008", "name": "50 Avenue des Champs u00c9lysu00e9es", "citycode": "75108", "context": "75, u00cele-de-France", "score": 0.9054545454545454, "type": "housenumber"}}], "type": "FeatureCollection", "attribution": "BAN"}', headers: {})
|
|
||||||
|
|
||||||
get :get_position, params: { dossier_id: dossier.id }
|
|
||||||
end
|
|
||||||
subject { JSON.parse(response.body) }
|
|
||||||
|
|
||||||
it 'format JSON valide' do
|
|
||||||
expect(response.content_type).to eq('application/json')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'latitude' do
|
|
||||||
expect(subject['lat']).to eq('48.870374')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'longitude' do
|
|
||||||
expect(subject['lon']).to eq('2.306888')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'dossier_id' do
|
|
||||||
expect(subject['dossier_id']).to eq(dossier.id.to_s)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'POST #get_qp' do
|
describe 'POST #get_qp' do
|
||||||
before do
|
before do
|
||||||
|
|
Loading…
Reference in a new issue