From 4f317e84d1e6cf7a83ebd0ef970705f90040e7cb Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Fri, 7 Feb 2020 15:35:09 +0100 Subject: [PATCH] Iterate over type_de_champ in repetition type_de_champ --- .../_show.html.haml | 5 +++++ .../manager/procedures_controller_spec.rb | 14 ++++++++++++++ spec/factories/procedure.rb | 9 +++++++++ 3 files changed, 28 insertions(+) diff --git a/app/views/fields/types_de_champ_collection_field/_show.html.haml b/app/views/fields/types_de_champ_collection_field/_show.html.haml index b0eda814f..772095b4e 100644 --- a/app/views/fields/types_de_champ_collection_field/_show.html.haml +++ b/app/views/fields/types_de_champ_collection_field/_show.html.haml @@ -10,5 +10,10 @@ - field.data.order(:order_place).each do |type_de_champ| = render partial: 'fields/types_de_champ_collection_field/type_champ_line', locals: { type_de_champ: type_de_champ } + + - if type_de_champ.type_champ == 'repetition' + - type_de_champ.types_de_champ.each do |sub_champ| + = render partial: 'fields/types_de_champ_collection_field/type_champ_line', + locals: { type_de_champ: sub_champ } - else Aucun diff --git a/spec/controllers/manager/procedures_controller_spec.rb b/spec/controllers/manager/procedures_controller_spec.rb index e4cd1ec45..b546a93e6 100644 --- a/spec/controllers/manager/procedures_controller_spec.rb +++ b/spec/controllers/manager/procedures_controller_spec.rb @@ -11,4 +11,18 @@ describe Manager::ProceduresController, type: :controller do it { expect(procedure.whitelisted_at).not_to be_nil } end + + describe '#show' do + render_views + + let(:administration) { create(:administration) } + let!(:procedure) { create(:procedure, :with_repetition) } + + before do + sign_in(administration) + get :show, params: { id: procedure.id } + end + + it { expect(response.body).to include('sub type de champ') } + end end diff --git a/spec/factories/procedure.rb b/spec/factories/procedure.rb index c15af065d..e233f0503 100644 --- a/spec/factories/procedure.rb +++ b/spec/factories/procedure.rb @@ -153,6 +153,15 @@ FactoryBot.define do end end + trait :with_repetition do + after(:build) do |procedure, _evaluator| + type_de_champ = create(:type_de_champ_repetition) + procedure.types_de_champ << type_de_champ + + type_de_champ.types_de_champ << create(:type_de_champ, libelle: 'sub type de champ') + end + end + trait :published do after(:build) do |procedure, _evaluator| procedure.path = generate(:published_path)