diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 2489f53d2..1e8d79bf9 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -89,7 +89,7 @@ class Procedure < ActiveRecord::Base end def clone - procedure = self.deep_clone(include: [:types_de_piece_justificative, :types_de_champ, :module_api_carto, :mail_templates]) + procedure = self.deep_clone(include: [:types_de_piece_justificative, :types_de_champ, :types_de_champ_private, :module_api_carto, :mail_templates]) procedure.archived = false procedure.published = false procedure.logo_secure_token = nil diff --git a/spec/models/procedure_spec.rb b/spec/models/procedure_spec.rb index 2b52bcb13..47356f165 100644 --- a/spec/models/procedure_spec.rb +++ b/spec/models/procedure_spec.rb @@ -163,6 +163,8 @@ describe Procedure do let(:procedure) { create(:procedure, archived: archived, published: published) } let!(:type_de_champ_0) { create(:type_de_champ_public, procedure: procedure, order_place: 0) } let!(:type_de_champ_1) { create(:type_de_champ_public, procedure: procedure, order_place: 1) } + let!(:type_de_champ_private_0) { create(:type_de_champ_private, procedure: procedure, order_place: 0) } + let!(:type_de_champ_private_1) { create(:type_de_champ_private, procedure: procedure, order_place: 1) } let!(:piece_justificative_0) { create(:type_de_piece_justificative, procedure: procedure, order_place: 0) } let!(:piece_justificative_1) { create(:type_de_piece_justificative, procedure: procedure, order_place: 1) } @@ -177,11 +179,19 @@ describe Procedure do expect(subject).to have_same_attributes_as(procedure) expect(subject.module_api_carto).to have_same_attributes_as(procedure.module_api_carto) + expect(subject.types_de_piece_justificative.size).to eq procedure.types_de_piece_justificative.size + expect(subject.types_de_champ.size).to eq procedure.types_de_champ.size + expect(subject.types_de_champ_private.size).to eq procedure.types_de_champ_private.size + expect(subject.mail_templates.size).to eq procedure.mail_templates.size subject.types_de_champ.zip(procedure.types_de_champ).each do |stc, ptc| expect(stc).to have_same_attributes_as(ptc) end + subject.types_de_champ_private.zip(procedure.types_de_champ_private).each do |stc, ptc| + expect(stc).to have_same_attributes_as(ptc) + end + subject.types_de_piece_justificative.zip(procedure.types_de_piece_justificative).each do |stc, ptc| expect(stc).to have_same_attributes_as(ptc) end