diff --git a/app/controllers/champs/carte_controller.rb b/app/controllers/champs/carte_controller.rb index 3fdd88b7b..4459ab781 100644 --- a/app/controllers/champs/carte_controller.rb +++ b/app/controllers/champs/carte_controller.rb @@ -39,14 +39,6 @@ class Champs::CarteController < ApplicationController end end - if @champ.quartiers_prioritaires? - quartiers_prioritaires = ApiCartoService.generate_qp(coordinates) - geo_areas += quartiers_prioritaires.map do |qp| - qp[:source] = GeoArea.sources.fetch(:quartier_prioritaire) - qp - end - end - selection_utilisateur = ApiCartoService.generate_selection_utilisateur(coordinates) selection_utilisateur[:source] = GeoArea.sources.fetch(:selection_utilisateur) geo_areas << selection_utilisateur diff --git a/app/javascript/components/TypesDeChampEditor/components/TypeDeChamp.js b/app/javascript/components/TypesDeChampEditor/components/TypeDeChamp.js index 5b4dc12fa..3787639e5 100644 --- a/app/javascript/components/TypesDeChampEditor/components/TypeDeChamp.js +++ b/app/javascript/components/TypesDeChampEditor/components/TypeDeChamp.js @@ -136,10 +136,6 @@ const TypeDeChamp = sortableElement( url={typeDeChamp.piece_justificative_template_url} /> - /.*/, - :headers => { 'Content-Type' => 'application/json' }) - .to_return(status: status, body: body) - end - context 'when geojson is empty' do - let(:geojson) { '' } - let(:status) { 404 } - let(:body) { '' } - - it 'raises ApiCarto::API::ResourceNotFound' do - expect { subject }.to raise_error(ApiCarto::API::ResourceNotFound) - end - end - - context 'when request return 500' do - let(:geojson) { File.read('spec/fixtures/files/api_carto/request_qp.json') } - let(:status) { 500 } - let(:body) { 'toto' } - - it 'raises ApiCarto::API::ResourceNotFound' do - expect { subject }.to raise_error(ApiCarto::API::ResourceNotFound) - end - end - - context 'when geojson exist' do - let(:geojson) { File.read('spec/fixtures/files/api_carto/request_qp.json') } - let(:status) { 200 } - let(:body) { 'toto' } - - it 'returns response body' do - expect(subject).to eq(body) - end - - context 'when geojson is at format JSON' do - let(:geojson) { JSON.parse(File.read('spec/fixtures/files/api_carto/request_qp.json')) } - - it 'returns response body' do - expect(subject).to eq(body) - end - end - end - end - describe '.search_cadastre' do subject { described_class.search_cadastre(geojson) } diff --git a/spec/lib/api_carto/quartiers_prioritaires_adapter_spec.rb b/spec/lib/api_carto/quartiers_prioritaires_adapter_spec.rb deleted file mode 100644 index 4f1988bae..000000000 --- a/spec/lib/api_carto/quartiers_prioritaires_adapter_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -describe ApiCarto::QuartiersPrioritairesAdapter do - subject { described_class.new(coordinates).results } - - before do - stub_request(:post, "https://sandbox.geo.api.gouv.fr/apicarto/quartiers-prioritaires/search") - .with(:body => /.*/, - :headers => { 'Content-Type' => 'application/json' }) - .to_return(status: status, body: body) - end - - context 'coordinates are filled' do - let(:coordinates) { '[[2.252728, 43.27151][2.323223, 32.835332]]' } - let(:status) { 200 } - let(:body) { File.read('spec/fixtures/files/api_carto/response_qp.json') } - - it { expect(subject).to be_a_instance_of(Array) } - - context 'Attributes' do - let(:qp_code) { 'QP057019' } - - it { expect(subject.first[:code]).to eq(qp_code) } - it { expect(subject.first[:nom]).to eq('Hauts De Vallières') } - it { expect(subject.first[:commune]).to eq('Metz') } - - it { expect(subject.first[:geometry]).to eq({ :type => "MultiPolygon", :coordinates => [[[[6.2136923480551, 49.1342109827851], [6.21416055031881, 49.1338823553928]]]] }) } - end - end - - context 'coordinates are empty' do - let(:coordinates) { '' } - let(:status) { 404 } - let(:body) { '' } - - it { expect { subject }.to raise_error(ApiCarto::API::ResourceNotFound) } - end -end diff --git a/spec/services/geojson_service_spec.rb b/spec/services/geojson_service_spec.rb index bcd9fdea3..7a3bd7c80 100644 --- a/spec/services/geojson_service_spec.rb +++ b/spec/services/geojson_service_spec.rb @@ -9,24 +9,6 @@ describe GeojsonService do ] } - describe '.toGeoJsonPolygonForQp' do - subject { JSON.parse(described_class.to_json_polygon_for_qp coordinates) } - - describe 'coordinates are empty' do - let(:coordinates) { '' } - - it { expect(subject['geo']['type']).to eq('Polygon') } - it { expect(subject['geo']['coordinates']).to eq([coordinates]) } - end - - describe 'coordinates are informed' do - let(:coordinates) { good_coordinates } - - it { expect(subject['geo']['type']).to eq('Polygon') } - it { expect(subject['geo']['coordinates']).to eq([coordinates]) } - end - end - describe '.toGeoJsonPolygonForCadastre' do subject { JSON.parse(described_class.to_json_polygon_for_cadastre coordinates) }