add witness dossier
This commit is contained in:
parent
951d964701
commit
e2130cc2d3
1 changed files with 53 additions and 11 deletions
|
@ -1,7 +1,5 @@
|
||||||
describe PiecesJustificativesService do
|
describe PiecesJustificativesService do
|
||||||
describe '.liste_documents' do
|
describe '.liste_documents' do
|
||||||
let(:procedure) { create(:procedure) }
|
|
||||||
let(:dossier) { create(:dossier, procedure: procedure) }
|
|
||||||
let(:for_expert) { false }
|
let(:for_expert) { false }
|
||||||
|
|
||||||
subject do
|
subject do
|
||||||
|
@ -12,21 +10,33 @@ describe PiecesJustificativesService do
|
||||||
|
|
||||||
context 'with a pj champ' do
|
context 'with a pj champ' do
|
||||||
let(:procedure) { create(:procedure, :with_piece_justificative) }
|
let(:procedure) { create(:procedure, :with_piece_justificative) }
|
||||||
let(:pj_champ) { dossier.champs.find { |c| c.type == 'Champs::PieceJustificativeChamp' } }
|
let(:dossier) { create(:dossier, procedure: procedure) }
|
||||||
|
let(:witness) { create(:dossier, procedure: procedure) }
|
||||||
|
|
||||||
before { attach_file_to_champ(pj_champ) }
|
let(:pj_champ) { -> (d) { d.champs.find { |c| c.type == 'Champs::PieceJustificativeChamp' } } }
|
||||||
|
|
||||||
it { expect(subject).to match_array([pj_champ.piece_justificative_file.attachment]) }
|
before do
|
||||||
|
attach_file_to_champ(pj_champ.call(dossier))
|
||||||
|
attach_file_to_champ(pj_champ.call(witness))
|
||||||
|
end
|
||||||
|
|
||||||
|
it { expect(subject).to match_array([pj_champ.call(dossier).piece_justificative_file.attachment]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with a private pj champ' do
|
context 'with a private pj champ' do
|
||||||
let(:procedure) { create(:procedure) }
|
let(:procedure) { create(:procedure) }
|
||||||
|
let(:dossier) { create(:dossier, procedure: procedure) }
|
||||||
|
let(:witness) { create(:dossier, procedure: procedure) }
|
||||||
|
|
||||||
let!(:private_pj) { create(:type_de_champ_piece_justificative, procedure: procedure, private: true) }
|
let!(:private_pj) { create(:type_de_champ_piece_justificative, procedure: procedure, private: true) }
|
||||||
let(:private_pj_champ) { dossier.champs_private.find { |c| c.type == 'Champs::PieceJustificativeChamp' } }
|
let(:private_pj_champ) { -> (d) { d.champs_private.find { |c| c.type == 'Champs::PieceJustificativeChamp' } } }
|
||||||
|
|
||||||
before { attach_file_to_champ(private_pj_champ) }
|
before do
|
||||||
|
attach_file_to_champ(private_pj_champ.call(dossier))
|
||||||
|
attach_file_to_champ(private_pj_champ.call(witness))
|
||||||
|
end
|
||||||
|
|
||||||
it { expect(subject).to match_array([private_pj_champ.piece_justificative_file.attachment]) }
|
it { expect(subject).to match_array([private_pj_champ.call(dossier).piece_justificative_file.attachment]) }
|
||||||
|
|
||||||
context 'for expert' do
|
context 'for expert' do
|
||||||
let(:for_expert) { true }
|
let(:for_expert) { true }
|
||||||
|
@ -37,6 +47,9 @@ describe PiecesJustificativesService do
|
||||||
|
|
||||||
context 'with a identite champ pj' do
|
context 'with a identite champ pj' do
|
||||||
let(:procedure) { create(:procedure, :with_titre_identite) }
|
let(:procedure) { create(:procedure, :with_titre_identite) }
|
||||||
|
let(:dossier) { create(:dossier, procedure: procedure) }
|
||||||
|
let(:witness) { create(:dossier, procedure: procedure) }
|
||||||
|
|
||||||
let(:champ_identite) { dossier.champs.find { |c| c.type == 'Champs::TitreIdentiteChamp' } }
|
let(:champ_identite) { dossier.champs.find { |c| c.type == 'Champs::TitreIdentiteChamp' } }
|
||||||
|
|
||||||
before { attach_file_to_champ(champ_identite) }
|
before { attach_file_to_champ(champ_identite) }
|
||||||
|
@ -48,19 +61,25 @@ describe PiecesJustificativesService do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with a pj on an commentaire' do
|
context 'with a pj on an commentaire' do
|
||||||
|
let(:dossier) { create(:dossier) }
|
||||||
|
let(:witness) { create(:dossier) }
|
||||||
|
|
||||||
let!(:commentaire) { create(:commentaire, :with_file, dossier: dossier) }
|
let!(:commentaire) { create(:commentaire, :with_file, dossier: dossier) }
|
||||||
|
let!(:witness_commentaire) { create(:commentaire, :with_file, dossier: witness) }
|
||||||
|
|
||||||
it { expect(subject).to match_array(dossier.commentaires.first.piece_jointe.attachment) }
|
it { expect(subject).to match_array(dossier.commentaires.first.piece_jointe.attachment) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with a motivation' do
|
context 'with a motivation' do
|
||||||
let(:dossier) { create(:dossier, :with_justificatif) }
|
let(:dossier) { create(:dossier, :with_justificatif) }
|
||||||
|
let!(:witness) { create(:dossier, :with_justificatif) }
|
||||||
|
|
||||||
it { expect(subject).to match_array(dossier.justificatif_motivation.attachment) }
|
it { expect(subject).to match_array(dossier.justificatif_motivation.attachment) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with an attestation' do
|
context 'with an attestation' do
|
||||||
let(:dossier) { create(:dossier, :with_attestation) }
|
let(:dossier) { create(:dossier, :with_attestation) }
|
||||||
|
let!(:witness) { create(:dossier, :with_attestation) }
|
||||||
|
|
||||||
it { expect(subject).to match_array(dossier.attestation.pdf.attachment) }
|
it { expect(subject).to match_array(dossier.attestation.pdf.attachment) }
|
||||||
end
|
end
|
||||||
|
@ -70,6 +89,10 @@ describe PiecesJustificativesService do
|
||||||
let(:attestation_sociale) { dossier.etablissement.entreprise_attestation_sociale }
|
let(:attestation_sociale) { dossier.etablissement.entreprise_attestation_sociale }
|
||||||
let(:attestation_fiscale) { dossier.etablissement.entreprise_attestation_fiscale }
|
let(:attestation_fiscale) { dossier.etablissement.entreprise_attestation_fiscale }
|
||||||
|
|
||||||
|
let!(:witness) { create(:dossier, :with_entreprise) }
|
||||||
|
let!(:witness_attestation_sociale) { witness.etablissement.entreprise_attestation_sociale }
|
||||||
|
let!(:witness_attestation_fiscale) { witness.etablissement.entreprise_attestation_fiscale }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
attach_file(attestation_sociale)
|
attach_file(attestation_sociale)
|
||||||
attach_file(attestation_fiscale)
|
attach_file(attestation_fiscale)
|
||||||
|
@ -79,13 +102,25 @@ describe PiecesJustificativesService do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with a bill' do
|
context 'with a bill' do
|
||||||
|
let(:dossier) { create(:dossier) }
|
||||||
|
let(:witness) { create(:dossier) }
|
||||||
|
|
||||||
let(:bill_signature) do
|
let(:bill_signature) do
|
||||||
bs = build(:bill_signature, :with_serialized, :with_signature)
|
bs = build(:bill_signature, :with_serialized, :with_signature)
|
||||||
bs.save(validate: false)
|
bs.save(validate: false)
|
||||||
bs
|
bs
|
||||||
end
|
end
|
||||||
|
|
||||||
before { create(:dossier_operation_log, dossier: dossier, bill_signature: bill_signature) }
|
let(:witness_bill_signature) do
|
||||||
|
bs = build(:bill_signature, :with_serialized, :with_signature)
|
||||||
|
bs.save(validate: false)
|
||||||
|
bs
|
||||||
|
end
|
||||||
|
|
||||||
|
before do
|
||||||
|
create(:dossier_operation_log, dossier: dossier, bill_signature: bill_signature)
|
||||||
|
create(:dossier_operation_log, dossier: witness, bill_signature: witness_bill_signature)
|
||||||
|
end
|
||||||
|
|
||||||
let(:dossier_bs) { dossier.dossier_operation_logs.first.bill_signature }
|
let(:dossier_bs) { dossier.dossier_operation_logs.first.bill_signature }
|
||||||
|
|
||||||
|
@ -101,9 +136,16 @@ describe PiecesJustificativesService do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with a dol' do
|
context 'with a dol' do
|
||||||
let(:dol) { create(:dossier_operation_log, dossier: dossier) }
|
let(:dossier) { create(:dossier) }
|
||||||
|
let(:witness) { create(:dossier) }
|
||||||
|
|
||||||
before { attach_file(dol.serialized) }
|
let(:dol) { create(:dossier_operation_log, dossier: dossier) }
|
||||||
|
let(:witness_dol) { create(:dossier_operation_log, dossier: witness) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
attach_file(dol.serialized)
|
||||||
|
attach_file(witness_dol.serialized)
|
||||||
|
end
|
||||||
|
|
||||||
it { expect(subject).to match_array(dol.serialized.attachment) }
|
it { expect(subject).to match_array(dol.serialized.attachment) }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue