Save Cadastre
This commit is contained in:
parent
b5f2163c51
commit
6a3525c7e2
8 changed files with 129 additions and 18 deletions
|
@ -3,7 +3,8 @@ require 'spec_helper'
|
|||
RSpec.describe Users::CarteController, type: :controller do
|
||||
let(:bad_adresse) { 'babouba' }
|
||||
|
||||
let(:procedure) { create(:procedure, :with_api_carto) }
|
||||
let(:module_api_carto) { create(:module_api_carto, :with_api_carto) }
|
||||
let(:procedure) { create(:procedure, module_api_carto: module_api_carto) }
|
||||
let(:dossier) { create(:dossier, :with_user, procedure: procedure) }
|
||||
|
||||
let(:dossier_with_no_carto) { create(:dossier, :with_user, :with_procedure) }
|
||||
|
@ -86,6 +87,8 @@ RSpec.describe Users::CarteController, type: :controller do
|
|||
end
|
||||
|
||||
describe 'Save quartier prioritaire' do
|
||||
let(:module_api_carto) { create(:module_api_carto, :with_quartiers_prioritaires) }
|
||||
|
||||
before do
|
||||
allow_any_instance_of(CARTO::SGMAP::QuartiersPrioritaires::Adapter).
|
||||
to receive(:to_params).
|
||||
|
@ -117,10 +120,6 @@ RSpec.describe Users::CarteController, type: :controller do
|
|||
context 'when json_latlngs params is informed' do
|
||||
let(:json_latlngs) { '[[{"lat":48.87442541960633,"lng":2.3859214782714844},{"lat":48.87273183590832,"lng":2.3850631713867183},{"lat":48.87081237174292,"lng":2.3809432983398438},{"lat":48.8712640169951,"lng":2.377510070800781},{"lat":48.87510283703279,"lng":2.3778533935546875},{"lat":48.87544154230615,"lng":2.382831573486328},{"lat":48.87442541960633,"lng":2.3859214782714844}]]' }
|
||||
|
||||
before do
|
||||
dossier.reload
|
||||
end
|
||||
|
||||
it { expect(dossier.quartier_prioritaires.size).to eq(1) }
|
||||
|
||||
describe 'Quartier Prioritaire' do
|
||||
|
@ -133,6 +132,59 @@ RSpec.describe Users::CarteController, type: :controller do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Save cadastre' do
|
||||
let(:module_api_carto) { create(:module_api_carto, :with_cadastre) }
|
||||
|
||||
before do
|
||||
allow_any_instance_of(CARTO::SGMAP::Cadastre::Adapter).
|
||||
to receive(:to_params).
|
||||
and_return([{:surface_intersection=>"0.0006", :surface_parcelle=>11252.692583090324, :numero=>"0013", :feuille=>1, :section=>"CD", :code_dep=>"30", :nom_com=>"Le Grau-du-Roi", :code_com=>"133", :code_arr=>"000", :geometry=>{:type=>"MultiPolygon", :coordinates=>[[[[4.134084, 43.5209193], [4.1346615, 43.5212035], [4.1346984, 43.521189], [4.135096, 43.5213848], [4.1350839, 43.5214122], [4.1352697, 43.521505], [4.1356278, 43.5211065], [4.1357402, 43.5207188], [4.1350935, 43.5203936], [4.135002, 43.5204366], [4.1346051, 43.5202412], [4.134584, 43.5202472], [4.1345572, 43.5202551], [4.134356, 43.5203137], [4.1342488, 43.5203448], [4.134084, 43.5209193]]]]}}])
|
||||
|
||||
post :save, dossier_id: dossier.id, json_latlngs: json_latlngs
|
||||
end
|
||||
|
||||
context 'when json_latlngs params is empty' do
|
||||
context 'when dossier have cadastres in database' do
|
||||
let!(:dossier) { create(:dossier, :with_user, :with_procedure, :with_two_cadastres) }
|
||||
|
||||
before do
|
||||
dossier.reload
|
||||
end
|
||||
|
||||
context 'when value is empty' do
|
||||
let(:json_latlngs) { '' }
|
||||
it { expect(dossier.cadastres.size).to eq(0) }
|
||||
end
|
||||
|
||||
context 'when value is empty array' do
|
||||
let(:json_latlngs) { '[]' }
|
||||
it { expect(dossier.cadastres.size).to eq(0) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when json_latlngs params is informed' do
|
||||
let(:json_latlngs) { '[[{"lat":48.87442541960633,"lng":2.3859214782714844},{"lat":48.87273183590832,"lng":2.3850631713867183},{"lat":48.87081237174292,"lng":2.3809432983398438},{"lat":48.8712640169951,"lng":2.377510070800781},{"lat":48.87510283703279,"lng":2.3778533935546875},{"lat":48.87544154230615,"lng":2.382831573486328},{"lat":48.87442541960633,"lng":2.3859214782714844}]]' }
|
||||
|
||||
it { expect(dossier.cadastres.size).to eq(1) }
|
||||
|
||||
describe 'Cadastre' do
|
||||
subject { Cadastre.last }
|
||||
|
||||
it { expect(subject.surface_intersection).to eq('0.0006') }
|
||||
it { expect(subject.surface_parcelle).to eq(11252.6925830903) }
|
||||
it { expect(subject.numero).to eq('0013') }
|
||||
it { expect(subject.feuille).to eq(1) }
|
||||
it { expect(subject.section).to eq('CD') }
|
||||
it { expect(subject.code_dep).to eq('30') }
|
||||
it { expect(subject.nom_com).to eq('Le Grau-du-Roi') }
|
||||
it { expect(subject.code_com).to eq('133') }
|
||||
it { expect(subject.code_arr).to eq('000') }
|
||||
it { expect(subject.geometry).to eq({"type"=>"MultiPolygon", "coordinates"=>[[[[4.134084, 43.5209193], [4.1346615, 43.5212035], [4.1346984, 43.521189], [4.135096, 43.5213848], [4.1350839, 43.5214122], [4.1352697, 43.521505], [4.1356278, 43.5211065], [4.1357402, 43.5207188], [4.1350935, 43.5203936], [4.135002, 43.5204366], [4.1346051, 43.5202412], [4.134584, 43.5202472], [4.1345572, 43.5202551], [4.134356, 43.5203137], [4.1342488, 43.5203448], [4.134084, 43.5209193]]]]}) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#get_position' do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue