Iterate over type_de_champ in repetition type_de_champ

This commit is contained in:
simon lehericey 2020-02-07 15:35:09 +01:00 committed by GitHub Action
parent a62e9fe6d2
commit 4f317e84d1
3 changed files with 28 additions and 0 deletions

View file

@ -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

View file

@ -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

View file

@ -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)