diff --git a/app/controllers/champs/carte_controller.rb b/app/controllers/champs/carte_controller.rb index 857970ac2..9746896a5 100644 --- a/app/controllers/champs/carte_controller.rb +++ b/app/controllers/champs/carte_controller.rb @@ -28,7 +28,7 @@ class Champs::CarteController < ApplicationController geo_areas = [] geo_json = geo_json.blank? ? [] : JSON.parse(geo_json) - if geo_json.first == ["error", "TooManyPolygons"] + if geo_json.empty? @error = true @champ.value = nil @champ.geo_areas = [] diff --git a/app/javascript/shared/carte.js b/app/javascript/shared/carte.js index 5a86af744..1c7d7655e 100644 --- a/app/javascript/shared/carte.js +++ b/app/javascript/shared/carte.js @@ -115,7 +115,7 @@ export function addFreeDrawEvents(map, selector) { } else if (polygonArea(latLngs) < 300000) { input.value = JSON.stringify(latLngs); } else { - input.value = '{ "error": "TooManyPolygons" }'; + input.value = ''; } fire(input, 'change'); diff --git a/spec/controllers/champs/carte_controller_spec.rb b/spec/controllers/champs/carte_controller_spec.rb index 267f6d3b2..9bd6c7627 100644 --- a/spec/controllers/champs/carte_controller_spec.rb +++ b/spec/controllers/champs/carte_controller_spec.rb @@ -50,7 +50,7 @@ describe Champs::CarteController, type: :controller 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(:selection) { { error: "TooManyPolygons" } } + let(:selection) { '' } it { expect(champ.reload.value).to eq(nil)