Do not send error json to backend - it doesn’t need it and it creates bad data

This commit is contained in:
Paul Chavard 2018-11-27 11:31:03 +01:00
parent 3915d2a579
commit f2e7feec1d
3 changed files with 3 additions and 3 deletions

View file

@ -28,7 +28,7 @@ class Champs::CarteController < ApplicationController
geo_areas = [] geo_areas = []
geo_json = geo_json.blank? ? [] : JSON.parse(geo_json) geo_json = geo_json.blank? ? [] : JSON.parse(geo_json)
if geo_json.first == ["error", "TooManyPolygons"] if geo_json.empty?
@error = true @error = true
@champ.value = nil @champ.value = nil
@champ.geo_areas = [] @champ.geo_areas = []

View file

@ -115,7 +115,7 @@ export function addFreeDrawEvents(map, selector) {
} else if (polygonArea(latLngs) < 300000) { } else if (polygonArea(latLngs) < 300000) {
input.value = JSON.stringify(latLngs); input.value = JSON.stringify(latLngs);
} else { } else {
input.value = '{ "error": "TooManyPolygons" }'; input.value = '';
} }
fire(input, 'change'); fire(input, 'change');

View file

@ -50,7 +50,7 @@ describe Champs::CarteController, type: :controller do
context 'when error' do context 'when error' do
let(:geojson) { [[{ "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 }]] } let(:geojson) { [[{ "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 }]] }
let(:selection) { { error: "TooManyPolygons" } } let(:selection) { '' }
it { it {
expect(champ.reload.value).to eq(nil) expect(champ.reload.value).to eq(nil)