Remove legacy carto
This commit is contained in:
parent
c4c1c971ca
commit
901b6e23a8
17 changed files with 10 additions and 572 deletions
|
@ -18,6 +18,7 @@ describe Champs::CarteController, type: :controller do
|
|||
cadastres: true
|
||||
}).champ.create(dossier: dossier)
|
||||
end
|
||||
|
||||
describe 'features' do
|
||||
let(:feature) { attributes_for(:geo_area, :polygon) }
|
||||
let(:geo_area) { create(:geo_area, :selection_utilisateur, :polygon, champ: champ) }
|
||||
|
@ -138,103 +139,4 @@ describe Champs::CarteController, type: :controller do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #show' do
|
||||
render_views
|
||||
|
||||
context 'when the API is available' do
|
||||
render_views
|
||||
|
||||
before do
|
||||
sign_in user
|
||||
|
||||
allow_any_instance_of(ApiCarto::CadastreAdapter)
|
||||
.to receive(:results)
|
||||
.and_return([{ code: "QPCODE1234", surface_parcelle: 4, geometry: { type: "MultiPolygon", coordinates: [[[[2.38715792094576, 48.8723062632126], [2.38724851642619, 48.8721392348061], [2.38724851642620, 48.8721392348064], [2.38715792094576, 48.8723062632126]]]] } }])
|
||||
|
||||
post :show, params: params, format: 'js'
|
||||
end
|
||||
|
||||
context 'when coordinates are empty' do
|
||||
let(:value) do
|
||||
{
|
||||
type: 'FeatureCollection',
|
||||
features: []
|
||||
}.to_json
|
||||
end
|
||||
|
||||
it {
|
||||
expect(assigns(:error)).to eq(nil)
|
||||
expect(champ.reload.value).to eq(nil)
|
||||
expect(champ.reload.geo_areas).to eq([])
|
||||
expect(response.body).to include("DS.fire('carte:update'")
|
||||
}
|
||||
end
|
||||
|
||||
context 'when coordinates are informed' do
|
||||
let(:value) do
|
||||
{
|
||||
type: 'FeatureCollection',
|
||||
features: [
|
||||
{
|
||||
type: 'Feature',
|
||||
properties: {
|
||||
source: 'selection_utilisateur'
|
||||
},
|
||||
geometry: { type: 'Polygon', coordinates: [[[2.3859214782714844, 48.87442541960633], [2.3850631713867183, 48.87273183590832], [2.3809432983398438, 48.87081237174292], [2.377510070800781, 48.8712640169951], [2.3859214782714844, 48.87442541960633]]] }
|
||||
}
|
||||
]
|
||||
}.to_json
|
||||
end
|
||||
|
||||
it {
|
||||
expect(response.body).not_to be_nil
|
||||
expect(response.body).to include('MultiPolygon')
|
||||
expect(response.body).to include('[2.38715792094576,48.8723062632126]')
|
||||
}
|
||||
end
|
||||
|
||||
context 'when error' do
|
||||
let(:value) { '' }
|
||||
|
||||
it {
|
||||
expect(assigns(:error)).to eq(true)
|
||||
expect(champ.reload.value).to eq(nil)
|
||||
expect(champ.reload.geo_areas).to eq([])
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the API is unavailable' do
|
||||
before do
|
||||
sign_in user
|
||||
|
||||
allow_any_instance_of(ApiCarto::CadastreAdapter)
|
||||
.to receive(:results)
|
||||
.and_raise(ApiCarto::API::ResourceNotFound)
|
||||
|
||||
post :show, params: params, format: 'js'
|
||||
end
|
||||
|
||||
let(:value) do
|
||||
{
|
||||
type: 'FeatureCollection',
|
||||
features: [
|
||||
{
|
||||
type: 'Feature',
|
||||
properties: {
|
||||
source: 'selection_utilisateur'
|
||||
},
|
||||
geometry: { type: 'Polygon', coordinates: [[[2.3859214782714844, 48.87442541960633], [2.3850631713867183, 48.87273183590832], [2.3809432983398438, 48.87081237174292], [2.377510070800781, 48.8712640169951], [2.3859214782714844, 48.87442541960633]]] }
|
||||
}
|
||||
]
|
||||
}.to_json
|
||||
end
|
||||
|
||||
it {
|
||||
expect(response.status).to eq 503
|
||||
expect(response.body).to include('Les données cartographiques sont temporairement indisponibles')
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,34 +15,6 @@ describe Champs::CarteChamp do
|
|||
}
|
||||
end
|
||||
|
||||
describe '#to_render_data' do
|
||||
subject { champ.to_render_data }
|
||||
|
||||
let(:render_data) {
|
||||
{
|
||||
position: champ.position,
|
||||
selection: selection,
|
||||
cadastres: [],
|
||||
parcellesAgricoles: [],
|
||||
quartiersPrioritaires: []
|
||||
}
|
||||
}
|
||||
|
||||
context 'when has no geo_areas' do
|
||||
let(:geo_areas) { [] }
|
||||
let(:selection) { nil }
|
||||
|
||||
it { is_expected.to eq(render_data) }
|
||||
end
|
||||
|
||||
context 'when has one geo_area' do
|
||||
let(:geo_areas) { [build(:geo_area, :selection_utilisateur, geometry: geo_json)] }
|
||||
let(:selection) { legacy_geo_json }
|
||||
|
||||
it { is_expected.to eq(render_data) }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#to_feature_collection' do
|
||||
subject { champ.to_feature_collection }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue