Merge pull request #7660 from tchak/use-new-factory

refactor(spec): use new procedure.types_de_champ factory
This commit is contained in:
Paul Chavard 2022-08-04 14:41:31 +02:00 committed by GitHub
commit 8e8d8d4f55
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 109 additions and 186 deletions

View file

@ -690,12 +690,11 @@ describe Administrateurs::ProceduresController, type: :controller do
context 'procedure revision is invalid' do
let(:path) { 'new_path' }
let(:empty_repetition) { build(:type_de_champ_repetition, types_de_champ: []) }
let(:procedure) do
create(:procedure,
administrateur: admin,
lien_site_web: lien_site_web,
types_de_champ: [empty_repetition])
types_de_champ_public: [{ type: :repetition, children: [] }])
end
it { expect { put :publish, params: { procedure_id: procedure.id, path: path, lien_site_web: lien_site_web } }.to raise_error(ActiveRecord::RecordInvalid) }

View file

@ -587,10 +587,8 @@ describe API::V2::GraphqlController do
end
context "champs" do
let(:procedure) { create(:procedure, :published, :for_individual, administrateurs: [admin], types_de_champ: [type_de_champ_date, type_de_champ_datetime]) }
let(:procedure) { create(:procedure, :published, :for_individual, administrateurs: [admin], types_de_champ_public: [{ type: :date }, { type: :datetime }]) }
let(:dossier) { create(:dossier, :en_construction, procedure: procedure) }
let(:type_de_champ_date) { build(:type_de_champ_date) }
let(:type_de_champ_datetime) { build(:type_de_champ_datetime) }
let(:champ_date) { dossier.champs.first }
let(:champ_datetime) { dossier.champs.second }

View file

@ -642,15 +642,12 @@ describe Instructeurs::DossiersController, type: :controller do
describe "#update_annotations" do
let(:procedure) do
procedure = create(:procedure, :published, types_de_champ_private: [
build(:type_de_champ_multiple_drop_down_list, position: 0),
build(:type_de_champ_linked_drop_down_list, position: 1),
build(:type_de_champ_datetime, position: 2)
create(:procedure, :published, types_de_champ_private: [
{ type: :multiple_drop_down_list },
{ type: :linked_drop_down_list },
{ type: :datetime },
{ type: :repetition, children: [{}] }
], instructeurs: instructeurs)
create(:type_de_champ_repetition, :with_types_de_champ, procedure: procedure, position: 3, private: true)
procedure
end
let(:dossier) { create(:dossier, :en_construction, :with_populated_annotations, procedure: procedure) }
let(:another_instructeur) { create(:instructeur) }

View file

@ -29,18 +29,24 @@ FactoryBot.define do
end
after(:build) do |procedure, evaluator|
if evaluator.types_de_champ.present?
raise "use types_de_champ_public instead of types_de_champ"
end
initial_revision = build(:procedure_revision, procedure: procedure, attestation_template: evaluator.attestation_template, dossier_submitted_message: evaluator.dossier_submitted_message)
if evaluator.types_de_champ_public.present?
if !evaluator.types_de_champ_public.first.is_a?(Hash)
raise "types_de_champ_public must be an array of hashes"
end
build_types_de_champ(evaluator.types_de_champ_public, revision: initial_revision, scope: :public)
end
add_types_de_champs(evaluator.types_de_champ, to: initial_revision, scope: :public)
if evaluator.types_de_champ_private.present?
if evaluator.types_de_champ_private.first.is_a?(Hash)
build_types_de_champ(evaluator.types_de_champ_private, revision: initial_revision, scope: :private)
else
add_types_de_champs(evaluator.types_de_champ_private, to: initial_revision, scope: :private)
if !evaluator.types_de_champ_private.first.is_a?(Hash)
raise "types_de_champ_private must be an array of hashes"
end
build_types_de_champ(evaluator.types_de_champ_private, revision: initial_revision, scope: :private)
end
if procedure.brouillon?
@ -370,19 +376,19 @@ end
def build_types_de_champ(types_de_champ, revision:, scope: :public, parent: nil)
types_de_champ.deep_dup.each.with_index do |type_de_champ_attributes, i|
type = TypeDeChamp.type_champs.fetch(type_de_champ_attributes.delete(:type) || :text)
type = TypeDeChamp.type_champs.fetch(type_de_champ_attributes.delete(:type) || :text).to_sym
position = type_de_champ_attributes.delete(:position) || i
children = type_de_champ_attributes.delete(:children)
options = type_de_champ_attributes.delete(:options)
layers = type_de_champ_attributes.delete(:layers)
if options.present?
if !options.nil?
if type == :drop_down_list
type_de_champ_attributes[:drop_down_other] = options.delete(:other).present?
end
if type.in?([:drop_down_list, :multiple_drop_down_list, :linked_drop_down_list])
type_de_champ_attributes[:drop_down_options] = options
type_de_champ_attributes[:drop_down_list_value] = options.join("\r\n")
end
end
@ -436,17 +442,3 @@ def build_types_de_champ(types_de_champ, revision:, scope: :public, parent: nil)
revision.association(:types_de_champ_private).target = revision.revision_types_de_champ_private.map(&:type_de_champ)
end
end
def add_types_de_champs(types_de_champ, to: nil, scope: :public)
revision = to
association_name = scope == :private ? :revision_types_de_champ_private : :revision_types_de_champ_public
types_de_champ.each.with_index do |type_de_champ, i|
type_de_champ.private = (scope == :private)
revision.public_send(association_name) << build(:procedure_revision_type_de_champ,
revision: revision,
position: i,
type_de_champ: type_de_champ)
end
end

View file

@ -27,7 +27,7 @@ RSpec.describe Types::DossierType, type: :graphql do
end
describe 'dossier with champs' do
let(:procedure) { create(:procedure, :published, :with_commune, :with_address) }
let(:procedure) { create(:procedure, :published, types_de_champ_public: [{ type: :communes }, { type: :address }]) }
let(:dossier) { create(:dossier, :accepte, :with_populated_champs, procedure: procedure) }
let(:query) { DOSSIER_WITH_CHAMPS_QUERY }
let(:variables) { { number: dossier.id } }

View file

@ -93,7 +93,7 @@ describe AttestationTemplate, type: :model do
describe 'attestation_for' do
let(:procedure) do
create(:procedure,
types_de_champ: types_de_champ,
types_de_champ_public: types_de_champ,
types_de_champ_private: types_de_champ_private,
for_individual: for_individual,
attestation_template: attestation_template)
@ -140,8 +140,8 @@ describe AttestationTemplate, type: :model do
context 'when the procedure has a type de champ named libelleA et libelleB' do
let(:types_de_champ) do
[
create(:type_de_champ, libelle: 'libelleA'),
create(:type_de_champ, libelle: 'libelleB')
{ libelle: 'libelleA' },
{ libelle: 'libelleB' }
]
end

View file

@ -2,19 +2,20 @@ describe Champs::HeaderSectionChamp do
describe '#section_index' do
let(:types_de_champ) do
[
build(:type_de_champ_header_section, position: 1),
build(:type_de_champ_civilite, position: 2),
build(:type_de_champ_text, position: 3),
build(:type_de_champ_header_section, position: 4),
build(:type_de_champ_email, position: 5)
{ type: :header_section },
{ type: :civilite },
{ type: :text },
{ type: :header_section },
{ type: :email }
]
end
let(:types_de_champ_public) { types_de_champ }
let(:procedure) { create(:procedure, types_de_champ_public: types_de_champ_public) }
let(:dossier) { create(:dossier, procedure: procedure) }
context 'for root-level champs' do
let(:procedure) { create(:procedure, types_de_champ: types_de_champ) }
let(:dossier) { create(:dossier, procedure: procedure) }
let(:first_header) { dossier.champs[0] }
let(:second_header) { dossier.champs[3] }
let(:first_header) { dossier.champs.first }
let(:second_header) { dossier.champs.fourth }
it 'returns the index of the section (starting from 1)' do
expect(first_header.section_index).to eq 1
@ -23,25 +24,10 @@ describe Champs::HeaderSectionChamp do
end
context 'for repetition champs' do
let(:procedure) { create(:procedure, :with_repetition) }
let(:dossier) { create(:dossier, procedure: procedure) }
let(:types_de_champ_public) { [{ type: :repetition, children: types_de_champ }] }
let(:first_header) { dossier.champs.first.champs[0] }
let(:second_header) { dossier.champs.first.champs[3] }
before do
revision = procedure.active_revision
tdc_repetition = revision.types_de_champ_public.first
revision.remove_type_de_champ(revision.children_of(tdc_repetition))
types_de_champ.each do |tdc|
revision.add_type_de_champ(
libelle: tdc.libelle,
type_champ: tdc.type_champ,
parent_stable_id: tdc_repetition.stable_id
)
end
end
let(:first_header) { dossier.champs.first.champs.first }
let(:second_header) { dossier.champs.first.champs.fourth }
it 'returns the index of the section in the repetition (starting from 1)' do
expect(first_header.section_index).to eq 1

View file

@ -704,7 +704,7 @@ describe Dossier do
end
describe "#unspecified_attestation_champs" do
let(:procedure) { create(:procedure, attestation_template: attestation_template, types_de_champ: types_de_champ, types_de_champ_private: types_de_champ_private) }
let(:procedure) { create(:procedure, attestation_template: attestation_template, types_de_champ_public: types_de_champ, types_de_champ_private: types_de_champ_private) }
let(:dossier) { create(:dossier, :en_instruction, procedure: procedure) }
let(:types_de_champ) { [] }
let(:types_de_champ_private) { [] }
@ -739,14 +739,14 @@ describe Dossier do
let(:types_de_champ) { [tdc_1, tdc_2, tdc_3, tdc_4] }
let(:types_de_champ_private) { [tdc_5, tdc_6, tdc_7, tdc_8] }
let(:tdc_1) { build(:type_de_champ, libelle: "specified champ-in-title") }
let(:tdc_2) { build(:type_de_champ, libelle: "unspecified champ-in-title") }
let(:tdc_3) { build(:type_de_champ, libelle: "specified champ-in-body") }
let(:tdc_4) { build(:type_de_champ, libelle: "unspecified champ-in-body") }
let(:tdc_5) { build(:type_de_champ, private: true, libelle: "specified annotation privée-in-title") }
let(:tdc_6) { build(:type_de_champ, private: true, libelle: "unspecified annotation privée-in-title") }
let(:tdc_7) { build(:type_de_champ, private: true, libelle: "specified annotation privée-in-body") }
let(:tdc_8) { build(:type_de_champ, private: true, libelle: "unspecified annotation privée-in-body") }
let(:tdc_1) { { libelle: "specified champ-in-title" } }
let(:tdc_2) { { libelle: "unspecified champ-in-title" } }
let(:tdc_3) { { libelle: "specified champ-in-body" } }
let(:tdc_4) { { libelle: "unspecified champ-in-body" } }
let(:tdc_5) { { libelle: "specified annotation privée-in-title" } }
let(:tdc_6) { { libelle: "unspecified annotation privée-in-title" } }
let(:tdc_7) { { libelle: "specified annotation privée-in-body" } }
let(:tdc_8) { { libelle: "unspecified annotation privée-in-body" } }
before do
(dossier.champs + dossier.champs_private)

View file

@ -1,14 +1,14 @@
describe DubiousProcedure, type: :model do
describe '#all' do
let!(:procedure) { create(:procedure, types_de_champ: tdcs) }
let(:allowed_tdc) { build(:type_de_champ, libelle: 'fournir') }
let!(:procedure) { create(:procedure, types_de_champ_public: tdcs) }
let(:allowed_tdc) { { libelle: 'fournir' } }
subject { DubiousProcedure.all }
context 'with suspicious champs' do
let(:forbidden_tdcs) do
[
build(:type_de_champ, libelle: 'num de securite sociale, stp'),
build(:type_de_champ, libelle: "t'aurais une carte bancaire ?")
{ libelle: 'num de securite sociale, stp' },
{ libelle: "t'aurais une carte bancaire ?" }
]
end

View file

@ -448,20 +448,13 @@ describe Procedure do
service: service,
opendata: opendata,
attestation_template: build(:attestation_template, logo: logo, signature: signature),
types_de_champ: [type_de_champ_0, type_de_champ_1, type_de_champ_2, type_de_champ_pj],
types_de_champ_private: [type_de_champ_private_0, type_de_champ_private_1, type_de_champ_private_2],
types_de_champ_public: [{}, {}, { type: :drop_down_list }, { type: :piece_justificative }, { type: :repetition, children: [{}] }],
types_de_champ_private: [{}, {}, { type: :drop_down_list }, { type: :repetition, children: [{}] }],
api_particulier_token: '123456789012345',
api_particulier_scopes: ['cnaf_famille'])
end
let(:type_de_champ_0) { build(:type_de_champ, position: 0) }
let(:type_de_champ_1) { build(:type_de_champ, position: 1) }
let(:type_de_champ_2) { build(:type_de_champ_drop_down_list, position: 2) }
let(:type_de_champ_pj) { build(:type_de_champ_piece_justificative, position: 3, old_pj: { stable_id: 2713 }) }
let(:type_de_champ_repetition) { build(:type_de_champ_repetition, position: 4, procedure: procedure, types_de_champ: [build(:type_de_champ)]) }
let(:type_de_champ_private_0) { build(:type_de_champ, :private, position: 0) }
let(:type_de_champ_private_1) { build(:type_de_champ, :private, position: 1) }
let(:type_de_champ_private_2) { build(:type_de_champ_drop_down_list, :private, position: 2) }
let(:type_de_champ_private_repetition) { build(:type_de_champ_repetition, :private, position: 3, procedure: procedure, types_de_champ: [build(:type_de_champ, :private)]) }
let(:type_de_champ_repetition) { procedure.types_de_champ.last }
let(:type_de_champ_private_repetition) { procedure.types_de_champ_private.last }
let(:received_mail) { build(:received_mail) }
let(:from_library) { false }
let(:opendata) { true }
@ -476,9 +469,6 @@ describe Procedure do
let!(:assign_to_2) { create(:assign_to, procedure: procedure, groupe_instructeur: groupe_instructeur_1, instructeur: instructeur_2) }
before do
type_de_champ_repetition
type_de_champ_private_repetition
@procedure = procedure.clone(administrateur, from_library)
@procedure.save
end
@ -1156,13 +1146,8 @@ describe Procedure do
describe '#new_dossier' do
let(:procedure) do
create(:procedure,
types_de_champ: [
build(:type_de_champ_text, position: 0),
build(:type_de_champ_number, position: 1)
],
types_de_champ_private: [
build(:type_de_champ_textarea, :private)
])
types_de_champ_public: [{}, { type: :number }],
types_de_champ_private: [{ type: :textarea }])
end
let(:dossier) { procedure.active_revision.new_dossier }

View file

@ -49,13 +49,14 @@ describe DossierSerializer do
context 'when a type de champ PJ was cloned from a legacy PJ' do
let(:original_pj_id) { 3 }
let(:cloned_type_de_champ) do
build(:type_de_champ_piece_justificative,
{
type: :piece_justificative,
libelle: "Vidéo de votre demande de subvention",
description: "Pour optimiser vos chances, soignez la chorégraphie et privilégiez le chant polyphonique.\r\nRécupérer le formulaire vierge pour mon dossier : https://www.dance-academy.gouv.fr",
old_pj: { stable_id: original_pj_id },
position: 0)
old_pj: { stable_id: original_pj_id }
}
end
let(:procedure) { create(:procedure, :published, types_de_champ: [cloned_type_de_champ]) }
let(:procedure) { create(:procedure, :published, types_de_champ_public: [cloned_type_de_champ]) }
let(:dossier) { create(:dossier, procedure: procedure) }
let(:champ_pj) { dossier.champs.last }
@ -70,7 +71,7 @@ describe DossierSerializer do
types_de_piece_justificative: [
{
"id" => original_pj_id,
"libelle" => cloned_type_de_champ.libelle,
"libelle" => cloned_type_de_champ[:libelle],
"description" => 'Pour optimiser vos chances, soignez la chorégraphie et privilégiez le chant polyphonique.',
"lien_demarche" => 'https://www.dance-academy.gouv.fr',
"order_place" => 0

View file

@ -12,13 +12,14 @@ describe ProcedureSerializer do
context 'when a type PJ was cloned to a type champ PJ' do
let(:original_pj_id) { 3 }
let(:cloned_type_de_champ) do
build(:type_de_champ_piece_justificative,
{
type: :piece_justificative,
libelle: "Vidéo de votre demande de subvention",
description: "Pour optimiser vos chances, soignez la chorégraphie et privilégiez le chant polyphonique.\r\nRécupérer le formulaire vierge pour mon dossier : https://www.dance-academy.gouv.fr",
old_pj: { stable_id: original_pj_id },
position: 0)
old_pj: { stable_id: original_pj_id }
}
end
let(:procedure) { create(:procedure, :published, types_de_champ: [cloned_type_de_champ]) }
let(:procedure) { create(:procedure, :published, types_de_champ_public: [cloned_type_de_champ]) }
subject { ProcedureSerializer.new(procedure).serializable_hash }
@ -27,7 +28,7 @@ describe ProcedureSerializer do
types_de_piece_justificative: [
{
"id" => original_pj_id,
"libelle" => cloned_type_de_champ.libelle,
"libelle" => cloned_type_de_champ[:libelle],
"description" => 'Pour optimiser vos chances, soignez la chorégraphie et privilégiez le chant polyphonique.',
"lien_demarche" => 'https://www.dance-academy.gouv.fr',
"order_place" => 0

View file

@ -194,7 +194,7 @@ describe DossierProjectionService do
context 'for type_de_champ table: type_de_champ pays which needs external_id field' do
let(:table) { 'type_de_champ' }
let(:procedure) { create(:procedure, types_de_champ: [build(:type_de_champ_pays)]) }
let(:procedure) { create(:procedure, types_de_champ_public: [{ type: :pays }]) }
let(:dossier) { create(:dossier, procedure: procedure) }
let(:column) { dossier.procedure.types_de_champ.first.stable_id.to_s }
let!(:previous_locale) { I18n.locale }

View file

@ -190,11 +190,7 @@ describe PiecesJustificativesService do
end
describe '.generate_dossier_export' do
let(:procedure) do
create(:procedure, :with_piece_justificative).tap do |procedure|
create(:type_de_champ_repetition, procedure: procedure, types_de_champ: [create(:type_de_champ_piece_justificative, procedure: procedure, no_coordinate: true)])
end
end
let(:procedure) { create(:procedure, types_de_champ_public: [{ type: :repetition, children: [{ type: :piece_justificative }] }]) }
let(:dossier) { create(:dossier, :with_populated_champs, procedure: procedure) }
subject { PiecesJustificativesService.generate_dossier_export(Dossier.where(id: dossier.id)) }

View file

@ -47,17 +47,14 @@ describe 'Publishing a procedure', js: true do
end
context 'when the procedure has invalid champs' do
let(:empty_repetition) { build(:type_de_champ_repetition, types_de_champ: [], libelle: 'Enfants') }
let(:empty_drop_down) { build(:type_de_champ_drop_down_list, :without_selectable_values, libelle: 'Civilité') }
let!(:procedure) do
create(:procedure,
:with_path,
:with_service,
instructeurs: instructeurs,
administrateur: administrateur,
types_de_champ: [empty_repetition],
types_de_champ_private: [empty_drop_down])
types_de_champ_public: [{ type: :repetition, libelle: 'Enfants', children: [] }, { type: :drop_down_list, libelle: 'Civilité', options: [] }],
types_de_champ_private: [{ type: :drop_down_list, libelle: 'Civilité', options: [] }])
end
scenario 'an error message prevents the publication' do
@ -133,19 +130,19 @@ describe 'Publishing a procedure', js: true do
context 'when a procedure has dubious champs' do
let(:dubious_champs) do
[
build(:type_de_champ_text, libelle: 'NIR'),
build(:type_de_champ_text, libelle: 'carte bancaire')
{ libelle: 'NIR' },
{ libelle: 'carte bancaire' }
]
end
let(:not_dubious_champs) do
[build(:type_de_champ_text, libelle: 'Prénom')]
[{ libelle: 'Prénom' }]
end
let!(:procedure) do
create(:procedure,
:with_service,
instructeurs: instructeurs,
administrateur: administrateur,
types_de_champ: not_dubious_champs + dubious_champs)
types_de_champ_public: not_dubious_champs + dubious_champs)
end
scenario 'an admin can publish it, but a warning appears' do

View file

@ -151,13 +151,7 @@ describe 'The user' do
expect(page).to have_content('Supprimer', count: 1)
end
let(:simple_procedure) do
tdcs = [
build(:type_de_champ, mandatory: true, libelle: 'texte obligatoire'),
build(:type_de_champ, mandatory: false, libelle: 'texte optionnel')
]
create(:procedure, :published, :for_individual, types_de_champ: tdcs)
end
let(:simple_procedure) { create(:procedure, :published, :for_individual, types_de_champ_public: [{ mandatory: true, libelle: 'texte obligatoire' }, { mandatory: false, libelle: 'texte optionnel' }]) }
scenario 'save an incomplete dossier as draft but cannot not submit it', js: true do
log_in(user, simple_procedure)
@ -205,25 +199,9 @@ describe 'The user' do
end
end
let(:procedure_with_pj) do
tdcs = [build(:type_de_champ_piece_justificative, mandatory: true, libelle: 'Pièce justificative')]
create(:procedure, :published, :for_individual, types_de_champ: tdcs)
end
let(:procedure_with_pjs) do
tdcs = [
build(:type_de_champ_piece_justificative, mandatory: true, libelle: 'Pièce justificative 1', position: 1),
build(:type_de_champ_piece_justificative, mandatory: true, libelle: 'Pièce justificative 2', position: 2)
]
create(:procedure, :published, :for_individual, types_de_champ: tdcs)
end
let(:old_procedure_with_disabled_pj_validation) do
tdcs = [
create(:type_de_champ_piece_justificative, mandatory: true, libelle: 'Pièce justificative 1', position: 1, skip_pj_validation: true)
]
create(:procedure, :published, :for_individual, types_de_champ: tdcs)
end
let(:procedure_with_pj) { create(:procedure, :published, :for_individual, types_de_champ_public: [{ type: :piece_justificative, mandatory: true, libelle: 'Pièce justificative' }]) }
let(:procedure_with_pjs) { create(:procedure, :published, :for_individual, types_de_champ_public: [{ type: :piece_justificative, mandatory: true, libelle: 'Pièce justificative 1' }, { type: :piece_justificative, mandatory: true, libelle: 'Pièce justificative 2' }]) }
let(:old_procedure_with_disabled_pj_validation) { create(:procedure, :published, :for_individual, types_de_champ_public: [{ type: :piece_justificative, mandatory: true, libelle: 'Pièce justificative 1', skip_pj_validation: true }]) }
scenario 'add an attachment', js: true do
log_in(user, procedure_with_pjs)

View file

@ -2,11 +2,7 @@ describe 'dropdown list with other option activated', js: true do
let(:password) { 'my-s3cure-p4ssword' }
let!(:user) { create(:user, password: password) }
let(:type_de_champ) { build(:type_de_champ_drop_down_list, libelle: 'simple dropdown other', drop_down_list_value: list_items, drop_down_other: true) }
let(:procedure) do
create(:procedure, :published, :for_individual, types_de_champ: [type_de_champ])
end
let(:procedure) { create(:procedure, :published, :for_individual, types_de_champ_public: [{ type: :drop_down_list, libelle: 'simple dropdown other', options: options + [:other] }]) }
let(:user_dossier) { user.dossiers.first }
@ -16,12 +12,12 @@ describe 'dropdown list with other option activated', js: true do
click_on 'Commencer la démarche'
end
context 'with radios' do
let(:list_items) do
<<~END_OF_LIST
--Primary 1--
Secondary 1.1
Secondary 1.2
END_OF_LIST
let(:options) do
[
'--Primary 1--',
'Secondary 1.1',
'Secondary 1.2'
]
end
scenario 'Select other option and the other input hidden must appear', js: true do
@ -33,16 +29,16 @@ describe 'dropdown list with other option activated', js: true do
end
context 'with select' do
let(:list_items) do
<<~END_OF_LIST
--Primary 1--
Secondary 1.1
Secondary 1.2
Secondary 1.3
Secondary 1.4
Secondary 1.5
Secondary 1.6
END_OF_LIST
let(:options) do
[
'--Primary 1--',
'Secondary 1.1',
'Secondary 1.2',
'Secondary 1.3',
'Secondary 1.4',
'Secondary 1.5',
'Secondary 1.6'
]
end
scenario 'with a select and other, selecting a value save it (avoid hidden other_value to be sent)' do

View file

@ -2,22 +2,19 @@ describe 'linked dropdown lists' do
let(:password) { 'my-s3cure-p4ssword' }
let!(:user) { create(:user, password: password) }
let(:list_items) do
<<~END_OF_LIST
--Primary 1--
Secondary 1.1
Secondary 1.2
--Primary 2--
Secondary 2.1
Secondary 2.2
Secondary 2.3
END_OF_LIST
let(:options) do
[
'--Primary 1--',
'Secondary 1.1',
'Secondary 1.2',
'--Primary 2--',
'Secondary 2.1',
'Secondary 2.2',
'Secondary 2.3'
]
end
let!(:procedure) do
create(:procedure, :published, :for_individual, types_de_champ: [type_de_champ])
end
let(:type_de_champ) { build(:type_de_champ_linked_drop_down_list, libelle: 'linked dropdown', drop_down_list_value: list_items, mandatory: mandatory) }
let(:procedure) { create(:procedure, :published, :for_individual, types_de_champ_public: [{ type: :linked_drop_down_list, libelle: 'linked dropdown', options: options, mandatory: mandatory }]) }
let(:user_dossier) { user.dossiers.first }
context 'not mandatory' do