[#2180] Keep information that this type de champ was cloned from a PJ

This commit is contained in:
Frederic Merizen 2019-01-10 13:36:38 +01:00
parent 651fd6149b
commit 8cb509d192
3 changed files with 6 additions and 2 deletions

View file

@ -37,7 +37,7 @@ class TypeDeChamp < ApplicationRecord
belongs_to :parent, class_name: 'TypeDeChamp'
has_many :types_de_champ, foreign_key: :parent_id, class_name: 'TypeDeChamp', dependent: :destroy
store_accessor :options, :cadastres, :quartiers_prioritaires, :parcelles_agricoles
store_accessor :options, :cadastres, :quartiers_prioritaires, :parcelles_agricoles, :old_pj
# TODO simplify after migrating `options` column to (non YAML encoded) JSON
class MaybeYaml

View file

@ -55,7 +55,10 @@ class PiecesJustificativesService
type_champ: TypeDeChamp.type_champs.fetch(:piece_justificative),
description: description,
order_place: order_place,
mandatory: tpj.mandatory
mandatory: tpj.mandatory,
old_pj: {
stable_id: tpj.id
}
)
end
if types_de_champ.count > 1

View file

@ -396,6 +396,7 @@ describe Procedure do
expect(stc.libelle).to eq(ptpj.libelle)
expect(stc.description).to eq(ptpj.description)
expect(stc.mandatory).to eq(ptpj.mandatory)
expect(stc.old_pj[:stable_id]).to eq(ptpj.id)
end
end