[#2180] Do not double-expose migrated type PJ as type champ PJ

This commit is contained in:
Frederic Merizen 2019-01-10 18:50:12 +01:00
parent 63519f04c8
commit d01270eff2
2 changed files with 5 additions and 1 deletions

View file

@ -26,7 +26,7 @@ class DossierSerializer < ActiveModel::Serializer
has_many :champs, serializer: ChampSerializer has_many :champs, serializer: ChampSerializer
def champs def champs
champs = object.champs.to_a champs = object.champs.reject { |c| c.type_de_champ.old_pj.present? }
if object.expose_legacy_carto_api? if object.expose_legacy_carto_api?
champ_carte = champs.find do |champ| champ_carte = champs.find do |champ|

View file

@ -96,5 +96,9 @@ describe DossierSerializer do
] ]
) )
end end
it "does not expose the PJ as a champ" do
expect(subject[:champs]).not_to include(a_hash_including(type_de_champ: a_hash_including(id: migrated_type_champ.id)))
end
end end
end end