[Fix #508]Api GeoJson: export cadastre
This commit is contained in:
parent
9f2338a70a
commit
f34546cf2a
4 changed files with 32 additions and 1 deletions
17
app/serializers/cadastre_serializer.rb
Normal file
17
app/serializers/cadastre_serializer.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
class CadastreSerializer < ActiveModel::Serializer
|
||||
attributes :value, :type_de_champ
|
||||
|
||||
def value
|
||||
object.geometry
|
||||
end
|
||||
|
||||
def type_de_champ
|
||||
{
|
||||
id: -1,
|
||||
libelle: 'cadastre',
|
||||
type_champ: 'cadastre',
|
||||
order_place: -1,
|
||||
descripton: ''
|
||||
}
|
||||
end
|
||||
end
|
|
@ -23,7 +23,7 @@ class DossierSerializer < ActiveModel::Serializer
|
|||
has_many :types_de_piece_justificative
|
||||
|
||||
has_many :champs do
|
||||
object.champs + object.quartier_prioritaires
|
||||
object.champs + object.quartier_prioritaires + object.cadastres
|
||||
end
|
||||
|
||||
def email
|
||||
|
|
|
@ -247,6 +247,19 @@ describe API::V1::DossiersController do
|
|||
it { expect(subject[:type_de_champ]).to match({ id: -1, libelle: 'quartier prioritaire', type_champ: 'quartier_prioritaire', order_place: -1, descripton: ''}) }
|
||||
it { expect(subject[:value]).to match(dossier.quartier_prioritaires.first.geometry.symbolize_keys) }
|
||||
end
|
||||
|
||||
context 'when the dossier includes a cadastre' do
|
||||
before do
|
||||
dossier.cadastres << create(:cadastre)
|
||||
end
|
||||
|
||||
subject do
|
||||
super().find { |champ| champ[:type_de_champ][:type_champ] == 'cadastre' }
|
||||
end
|
||||
|
||||
it { expect(subject[:type_de_champ]).to match({ id: -1, libelle: 'cadastre', type_champ: 'cadastre', order_place: -1, descripton: ''}) }
|
||||
it { expect(subject[:value]).to match(dossier.cadastres.first.geometry.symbolize_keys) }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'champs_private' do
|
||||
|
|
|
@ -3,5 +3,6 @@ FactoryGirl.define do
|
|||
numero '001'
|
||||
feuille 1
|
||||
section 'OM'
|
||||
geometry '{"type": "MultiPolygon", "coordinates": [[[[2.37112834276229, 48.8773116214902], [2.37163254350824, 48.8775780792784], [2.37112834276229, 48.8773116214902]]]]}'
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue