Carte Editor sends FeatureCollection to the server

This commit is contained in:
Paul Chavard 2020-04-14 10:24:30 +02:00
parent 99c8300c10
commit bc8217e030
8 changed files with 98 additions and 55 deletions

View file

@ -36,7 +36,12 @@ describe Champs::CarteController, type: :controller do
end
context 'when coordinates are empty' do
let(:value) { '[]' }
let(:value) do
{
type: 'FeatureCollection',
features: []
}.to_json
end
it {
expect(assigns(:error)).to eq(nil)
@ -47,11 +52,26 @@ describe Champs::CarteController, type: :controller do
end
context 'when coordinates are informed' do
let(:value) { [[{ "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 }]].to_json }
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 }
it { expect(response.body).to include('MultiPolygon') }
it { expect(response.body).to include('[2.38715792094576,48.8723062632126]') }
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
@ -76,10 +96,25 @@ describe Champs::CarteController, type: :controller do
post :show, params: params, format: 'js'
end
let(:value) { [[{ "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 }]].to_json }
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 }
it { expect(response.body).to include('Les données cartographiques sont temporairement indisponibles') }
it {
expect(response.status).to eq 503
expect(response.body).to include('Les données cartographiques sont temporairement indisponibles')
}
end
end
end