From 9ac85295c696c35961d1c11d720a401eed5dd74d Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Tue, 6 Nov 2018 14:08:22 +0100 Subject: [PATCH] Do not serialize properties on carte champs --- app/helpers/champ_helper.rb | 6 +++--- spec/controllers/champs/carte_controller_spec.rb | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/helpers/champ_helper.rb b/app/helpers/champ_helper.rb index ef8f6386f..7f3df63d2 100644 --- a/app/helpers/champ_helper.rb +++ b/app/helpers/champ_helper.rb @@ -9,9 +9,9 @@ module ChampHelper raw({ position: champ.position, selection: champ.value.present? ? JSON.parse(champ.value) : [], - quartiersPrioritaires: champ.quartiers_prioritaires? ? champ.quartiers_prioritaires : [], - cadastres: champ.cadastres? ? champ.cadastres : [], - parcellesAgricoles: champ.parcelles_agricoles? ? champ.parcelles_agricoles : [] + quartiersPrioritaires: champ.quartiers_prioritaires? ? champ.quartiers_prioritaires.as_json(except: :properties) : [], + cadastres: champ.cadastres? ? champ.cadastres.as_json(except: :properties) : [], + parcellesAgricoles: champ.parcelles_agricoles? ? champ.parcelles_agricoles.as_json(except: :properties) : [] }.to_json) # rubocop:enable Rails/OutputSafety end diff --git a/spec/controllers/champs/carte_controller_spec.rb b/spec/controllers/champs/carte_controller_spec.rb index c4393bbcd..9a9d56896 100644 --- a/spec/controllers/champs/carte_controller_spec.rb +++ b/spec/controllers/champs/carte_controller_spec.rb @@ -43,7 +43,6 @@ describe Champs::CarteController, type: :controller do let(:selection) { [[{ "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 }]] } it { expect(response.body).not_to be_nil } - it { expect(response.body).to include('QPCODE1234') } it { expect(response.body).to include('MultiPolygon') } it { expect(response.body).to include('[2.38715792094576,48.8723062632126]') } end