diff --git a/spec/factories/procedure.rb b/spec/factories/procedure.rb index 3e05e2b55..f74e2da10 100644 --- a/spec/factories/procedure.rb +++ b/spec/factories/procedure.rb @@ -170,6 +170,12 @@ FactoryBot.define do end end + trait :with_titre_identite do + after(:build) do |procedure, _evaluator| + build(:type_de_champ_titre_identite, procedure: procedure) + end + end + trait :with_repetition do after(:build) do |procedure, _evaluator| build(:type_de_champ_repetition, :with_types_de_champ, procedure: procedure) diff --git a/spec/services/pieces_justificatives_service_spec.rb b/spec/services/pieces_justificatives_service_spec.rb new file mode 100644 index 000000000..d0ad55499 --- /dev/null +++ b/spec/services/pieces_justificatives_service_spec.rb @@ -0,0 +1,22 @@ +describe PiecesJustificativesService do + describe '.liste_pieces_justificatives' do + let(:procedure) { create(:procedure, :with_titre_identite) } + let(:dossier) { create(:dossier, procedure: procedure) } + let(:champ_identite) { dossier.champs.find { |c| c.type == 'Champs::TitreIdentiteChamp' } } + + before do + champ_identite + .piece_justificative_file + .attach(io: StringIO.new("toto"), filename: "toto.png", content_type: "image/png") + end + + subject { PiecesJustificativesService.liste_pieces_justificatives(dossier) } + + # titre identite is too sensitive + # to be exported + it 'ensures no titre identite is given' do + expect(champ_identite.piece_justificative_file).to be_attached + expect(subject).to eq([]) + end + end +end