2016-06-09 12:08:18 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Ban::SearchController, type: :controller do
|
2016-12-16 15:18:34 +01:00
|
|
|
describe '#GET get' do
|
2018-01-16 13:34:24 +01:00
|
|
|
subject { get :get, params: { request: request } }
|
2016-06-09 12:08:18 +02:00
|
|
|
|
|
|
|
before do
|
2016-12-16 17:51:07 +01:00
|
|
|
subject
|
|
|
|
end
|
|
|
|
|
2018-01-16 13:34:24 +01:00
|
|
|
context 'when request return result', vcr: { cassette_name: 'bano_search_paris' } do
|
2016-12-16 17:51:07 +01:00
|
|
|
let (:request) { 'Paris' }
|
2016-11-15 04:26:25 +01:00
|
|
|
|
2016-12-16 17:51:07 +01:00
|
|
|
it { expect(response.status).to eq 200 }
|
|
|
|
it { expect(response.body).to eq '[{"label":"Paris"},{"label":"Paris 63120 Courpière"},{"label":"PARIS (Vaillac) 46240 Cœur de Causse"},{"label":"Paris 40500 Saint-Sever"},{"label":"Paris Buton 37140 Bourgueil"}]' }
|
2016-06-09 12:08:18 +02:00
|
|
|
end
|
|
|
|
|
2018-01-16 13:34:24 +01:00
|
|
|
context 'when request return nothing', vcr: { cassette_name: 'bano_search_nothing' } do
|
2016-12-16 17:51:07 +01:00
|
|
|
let (:request) { 'je recherche pas grand chose' }
|
|
|
|
|
|
|
|
it { expect(response.status).to eq 200 }
|
|
|
|
it { expect(response.body).to eq "[]" }
|
|
|
|
end
|
2016-06-09 12:08:18 +02:00
|
|
|
end
|
2016-12-16 15:18:34 +01:00
|
|
|
|
|
|
|
describe '#GET get_address_point' do
|
|
|
|
let(:dossier_id) { "1" }
|
2018-01-16 13:34:24 +01:00
|
|
|
subject { get :get_address_point, params: { request: request, dossier_id: dossier_id } }
|
2016-12-16 15:18:34 +01:00
|
|
|
|
|
|
|
before do
|
|
|
|
subject
|
|
|
|
end
|
|
|
|
|
2018-01-16 13:34:24 +01:00
|
|
|
context 'when request return result', vcr: { cassette_name: 'ban_search_paris' } do
|
2016-12-16 15:18:34 +01:00
|
|
|
let(:request) { 'Paris' }
|
|
|
|
|
2018-01-16 13:34:24 +01:00
|
|
|
it { expect(response.body).to eq ({ lon: '2.3469', lat: '48.8589', zoom: '14', dossier_id: dossier_id }).to_json }
|
2016-12-16 15:18:34 +01:00
|
|
|
end
|
|
|
|
|
2018-01-16 13:34:24 +01:00
|
|
|
context 'when request return nothing', vcr: { cassette_name: 'ban_search_nothing' } do
|
2016-12-16 15:18:34 +01:00
|
|
|
let(:request) { 'je recherche pas grand chose' }
|
|
|
|
|
2018-01-16 13:34:24 +01:00
|
|
|
it { expect(response.body).to eq ({ lon: nil, lat: nil, zoom: '14', dossier_id: dossier_id }).to_json }
|
2016-12-16 15:18:34 +01:00
|
|
|
end
|
|
|
|
end
|
2016-06-09 12:08:18 +02:00
|
|
|
end
|