Merge commit '8f3c427'

This commit is contained in:
gregoirenovel 2018-10-16 12:45:13 +02:00
commit 56509e6ab9
7 changed files with 13 additions and 18 deletions

View file

@ -1,5 +1,5 @@
class Ban::SearchController < ApplicationController
def get
class AddressController < ApplicationController
def suggestions
request = params[:request]
json = ApiAdresse::AddressAdapter.new(request).get_suggestions.map do |value|
@ -9,7 +9,7 @@ class Ban::SearchController < ApplicationController
render json: json
end
def get_address_point
def geocode
request = params[:request]
point = ApiAdresse::PointAdapter.new(request).geocode

View file

@ -63,7 +63,7 @@ function addEventFreeDraw(freeDraw) {
}
function getAddressPoint(map, request) {
getJSON('/ban/address_point', { request }).then(data => {
getJSON('/address/geocode', { request }).then(data => {
if (data.lat !== null) {
map.setView(new L.LatLng(data.lat, data.lon), data.zoom);
}

View file

@ -4,7 +4,7 @@ import { getJSON, fire } from '@utils';
const sources = [
{
type: 'address',
url: '/ban/search'
url: '/address/suggestions'
},
{
type: 'path',

View file

@ -12,11 +12,9 @@ class ApiCarto::API
private
def self.call(url, geojson)
verify_ssl_mode = OpenSSL::SSL::VERIFY_NONE
params = geojson.to_s
client = RestClient::Resource.new(url, verify_ssl: verify_ssl_mode)
client.post(params, content_type: 'application/json')
RestClient.post(url, params, content_type: 'application/json')
rescue RestClient::InternalServerError
raise RestClient::ResourceNotFound

View file

@ -27,7 +27,6 @@ class ApiEntreprise::API
params = params(siret_or_siren, procedure_id)
response = Typhoeus.get(url,
ssl_verifypeer: false,
params: params,
timeout: TIMEOUT)

View file

@ -250,10 +250,8 @@ Rails.application.routes.draw do
# Addresses
#
namespace :ban do
get 'search' => 'search#get'
get 'address_point' => 'search#get_address_point'
end
get 'address/suggestions' => 'address#suggestions'
get 'address/geocode' => 'address#geocode'
namespace :invites do
post 'dossier/:dossier_id' => '/invites#create', as: 'dossier'

View file

@ -1,8 +1,8 @@
require 'spec_helper'
describe Ban::SearchController, type: :controller do
describe '#GET get' do
subject { get :get, params: { request: request } }
describe AddressController, type: :controller do
describe '#GET suggestions' do
subject { get :suggestions, params: { request: request } }
before do
subject
@ -23,9 +23,9 @@ describe Ban::SearchController, type: :controller do
end
end
describe '#GET get_address_point' do
describe '#GET geocode' do
let(:dossier_id) { "1" }
subject { get :get_address_point, params: { request: request, dossier_id: dossier_id } }
subject { get :geocode, params: { request: request, dossier_id: dossier_id } }
before do
subject