diff --git a/app/controllers/new_gestionnaire/dossiers_controller.rb b/app/controllers/new_gestionnaire/dossiers_controller.rb index 1b90932ba..ce56a4617 100644 --- a/app/controllers/new_gestionnaire/dossiers_controller.rb +++ b/app/controllers/new_gestionnaire/dossiers_controller.rb @@ -129,25 +129,6 @@ module NewGestionnaire 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 @avis = Avis.new(avis_params.merge(claimant: current_gestionnaire, dossier: dossier)) if @avis.save diff --git a/app/controllers/users/carte_controller.rb b/app/controllers/users/carte_controller.rb index 1e277dd06..a7c0ba8d1 100644 --- a/app/controllers/users/carte_controller.rb +++ b/app/controllers/users/carte_controller.rb @@ -28,36 +28,6 @@ class Users::CarteController < UsersController redirect_to brouillon_dossier_path(dossier) 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 { diff --git a/config/routes.rb b/config/routes.rb index 8bb7fb13b..154efcda4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -152,10 +152,6 @@ Rails.application.routes.draw do resources :dossiers do 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' post '/carte' => 'carte#save' @@ -333,9 +329,6 @@ Rails.application.routes.draw do post 'repasser-en-construction' => 'dossiers#repasser_en_construction' post 'terminer' post 'send-to-instructeurs' => 'dossiers#send_to_instructeurs' - scope :carte do - get 'position' - end post 'avis' => 'dossiers#create_avis' get 'print' => 'dossiers#print' end diff --git a/spec/controllers/users/carte_controller_shared_example.rb b/spec/controllers/users/carte_controller_shared_example.rb index 14be73f2c..0a0f9495b 100644 --- a/spec/controllers/users/carte_controller_shared_example.rb +++ b/spec/controllers/users/carte_controller_shared_example.rb @@ -210,68 +210,7 @@ shared_examples 'carte_controller_spec' do 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 before do