Save selection utilisateur as geo area

This commit is contained in:
Paul Chavard 2018-12-19 11:09:13 +01:00
parent 4325bc0689
commit c75e39884e
8 changed files with 94 additions and 46 deletions

View file

@ -3,9 +3,9 @@ require 'spec_helper'
describe Champs::CarteChamp do
let(:champ) { Champs::CarteChamp.new(value: value) }
let(:value) { '' }
let(:geo_json) { GeojsonService.to_json_polygon_for_selection_utilisateur(coordinates) }
let(:coordinates) { [[{ "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(:parsed_geo_json) { JSON.parse(geo_json) }
let(:geo_json_as_string) { GeojsonService.to_json_polygon_for_selection_utilisateur(coordinates) }
let(:geo_json) { JSON.parse(geo_json_as_string) }
describe '#to_render_data' do
subject { champ.to_render_data }
@ -47,15 +47,15 @@ describe Champs::CarteChamp do
context 'when the value is coordinates' do
let(:value) { coordinates.to_json }
let(:selection) { parsed_geo_json }
let(:selection) { geo_json }
it { is_expected.to eq(render_data) }
end
context 'when the value is geojson' do
let(:value) { geo_json }
let(:value) { geo_json.to_json }
let(:selection) { parsed_geo_json }
let(:selection) { geo_json }
it { is_expected.to eq(render_data) }
end
@ -89,7 +89,7 @@ describe Champs::CarteChamp do
end
context 'when the value is geojson' do
let(:value) { geo_json }
let(:value) { geo_json.to_json }
it { is_expected.to eq(1) }
end