[#2180] Only retain old PJ API when cloning for same admin
This commit is contained in:
parent
d1c0418c89
commit
5e37400834
2 changed files with 16 additions and 0 deletions
|
@ -205,6 +205,10 @@ class Procedure < ApplicationRecord
|
|||
[:notice, :deliberation].each { |attachment| clone_attachment(procedure, attachment) }
|
||||
|
||||
procedure.types_de_champ += PiecesJustificativesService.types_pj_as_types_de_champ(self)
|
||||
if is_different_admin || from_library
|
||||
procedure.types_de_champ.each { |tdc| tdc.options&.delete(:old_pj) }
|
||||
end
|
||||
|
||||
procedure.administrateur = admin
|
||||
procedure.initiated_mail = initiated_mail&.dup
|
||||
procedure.received_mail = received_mail&.dup
|
||||
|
|
|
@ -409,6 +409,12 @@ describe Procedure do
|
|||
it 'should set service_id to nil' do
|
||||
expect(subject.service).to eq(nil)
|
||||
end
|
||||
|
||||
it 'should discard old pj information' do
|
||||
subject.types_de_champ.each do |stc|
|
||||
expect(stc.old_pj).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it 'should keep service_id' do
|
||||
|
@ -423,6 +429,12 @@ describe Procedure do
|
|||
expect(subject.service.administrateur_id).not_to eq(service.administrateur_id)
|
||||
expect(subject.service.attributes.except("id", "administrateur_id", "created_at", "updated_at")).to eq(service.attributes.except("id", "administrateur_id", "created_at", "updated_at"))
|
||||
end
|
||||
|
||||
it 'should discard old pj information' do
|
||||
subject.types_de_champ.each do |stc|
|
||||
expect(stc.old_pj).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it 'should duplicate existing mail_templates' do
|
||||
|
|
Loading…
Reference in a new issue