ApiAdresse::AddressAdapter#list → #get_suggestions
This commit is contained in:
parent
517c0ad3fc
commit
7af41b35a2
3 changed files with 4 additions and 4 deletions
|
@ -2,7 +2,7 @@ class Ban::SearchController < ApplicationController
|
||||||
def get
|
def get
|
||||||
request = params[:request]
|
request = params[:request]
|
||||||
|
|
||||||
json = ApiAdresse::AddressAdapter.new(request).list.map do |value|
|
json = ApiAdresse::AddressAdapter.new(request).get_suggestions.map do |value|
|
||||||
{ label: value }
|
{ label: value }
|
||||||
end.to_json
|
end.to_json
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ class ApiAdresse::AddressAdapter
|
||||||
@address = address
|
@address = address
|
||||||
end
|
end
|
||||||
|
|
||||||
def list
|
def get_suggestions
|
||||||
@list ||= convert_api_result_to_full_address
|
@list ||= convert_api_result_to_full_address
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe ApiAdresse::AddressAdapter do
|
describe ApiAdresse::AddressAdapter do
|
||||||
describe '#list' do
|
describe '#get_suggestions' do
|
||||||
let(:request) { 'Paris' }
|
let(:request) { 'Paris' }
|
||||||
let(:response) { File.open('spec/support/files/api_adresse/search_results.json') }
|
let(:response) { File.open('spec/support/files/api_adresse/search_results.json') }
|
||||||
let(:status) { 200 }
|
let(:status) { 200 }
|
||||||
|
|
||||||
subject { described_class.new(request).list }
|
subject { described_class.new(request).get_suggestions }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_request(:get, "https://api-adresse.data.gouv.fr/search?&q=#{request}&limit=5")
|
stub_request(:get, "https://api-adresse.data.gouv.fr/search?&q=#{request}&limit=5")
|
||||||
|
|
Loading…
Reference in a new issue