From 6b39128be336d4ba624111a348ddee36b72ce75f Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Wed, 6 Feb 2019 10:02:05 +0100 Subject: [PATCH] Clone nested types_de_champ --- app/models/procedure.rb | 4 ++-- spec/models/type_de_champ_shared_example.rb | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 9b0eeb631..7fd28e5ed 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -190,8 +190,8 @@ class Procedure < ApplicationRecord procedure = self.deep_clone(include: { attestation_template: nil, - types_de_champ: :drop_down_list, - types_de_champ_private: :drop_down_list + types_de_champ: [:drop_down_list, types_de_champ: :drop_down_list], + types_de_champ_private: [:drop_down_list, types_de_champ: :drop_down_list] }) procedure.path = nil procedure.aasm_state = :brouillon diff --git a/spec/models/type_de_champ_shared_example.rb b/spec/models/type_de_champ_shared_example.rb index 1da8f1abb..d0b6e4ecf 100644 --- a/spec/models/type_de_champ_shared_example.rb +++ b/spec/models/type_de_champ_shared_example.rb @@ -141,6 +141,11 @@ shared_examples 'type_de_champ_spec' do type_de_champ.types_de_champ << type_de_champ_text expect(type_de_champ.types_de_champ.size).to eq(2) expect(type_de_champ_text.parent).to eq(type_de_champ) + + admin = create(:administrateur) + cloned_procedure = procedure.clone(admin, false) + + expect(cloned_procedure.types_de_champ.first.types_de_champ).not_to be_empty end end end