[Fix #508]Api GeoJson: export quartier_prioritaire
This commit is contained in:
parent
cc26eb6e87
commit
9f2338a70a
4 changed files with 35 additions and 1 deletions
|
@ -18,11 +18,14 @@ class DossierSerializer < ActiveModel::Serializer
|
||||||
has_one :etablissement
|
has_one :etablissement
|
||||||
has_many :cerfa
|
has_many :cerfa
|
||||||
has_many :commentaires
|
has_many :commentaires
|
||||||
has_many :champs
|
|
||||||
has_many :champs_private
|
has_many :champs_private
|
||||||
has_many :pieces_justificatives
|
has_many :pieces_justificatives
|
||||||
has_many :types_de_piece_justificative
|
has_many :types_de_piece_justificative
|
||||||
|
|
||||||
|
has_many :champs do
|
||||||
|
object.champs + object.quartier_prioritaires
|
||||||
|
end
|
||||||
|
|
||||||
def email
|
def email
|
||||||
object.user.try(:email)
|
object.user.try(:email)
|
||||||
end
|
end
|
||||||
|
|
17
app/serializers/quartier_prioritaire_serializer.rb
Normal file
17
app/serializers/quartier_prioritaire_serializer.rb
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
class QuartierPrioritaireSerializer < ActiveModel::Serializer
|
||||||
|
attributes :value, :type_de_champ
|
||||||
|
|
||||||
|
def value
|
||||||
|
object.geometry
|
||||||
|
end
|
||||||
|
|
||||||
|
def type_de_champ
|
||||||
|
{
|
||||||
|
id: -1,
|
||||||
|
libelle: 'quartier prioritaire',
|
||||||
|
type_champ: 'quartier_prioritaire',
|
||||||
|
order_place: -1,
|
||||||
|
descripton: ''
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
|
@ -234,6 +234,19 @@ describe API::V1::DossiersController do
|
||||||
it { expect(subject[:type_champ]).to eq('text') }
|
it { expect(subject[:type_champ]).to eq('text') }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when the dossier includes a quartier prioritaire' do
|
||||||
|
before do
|
||||||
|
dossier.quartier_prioritaires << create(:quartier_prioritaire)
|
||||||
|
end
|
||||||
|
|
||||||
|
subject do
|
||||||
|
super().find { |champ| champ[:type_de_champ][:type_champ] == 'quartier_prioritaire' }
|
||||||
|
end
|
||||||
|
|
||||||
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'champs_private' do
|
describe 'champs_private' do
|
||||||
|
|
|
@ -3,5 +3,6 @@ FactoryGirl.define do
|
||||||
code 'QPcode'
|
code 'QPcode'
|
||||||
commune 'Paris'
|
commune 'Paris'
|
||||||
nom 'Test des QP'
|
nom 'Test des QP'
|
||||||
|
geometry '{"type": "MultiPolygon", "coordinates": [[[[2.37112834276229, 48.8773116214902], [2.37163254350824, 48.8775780792784], [2.37112834276229, 48.8773116214902]]]]}'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue