specs: improve ProcedureExportService spec

This commit is contained in:
Pierre de La Morinerie 2020-05-13 13:57:40 +00:00 committed by GitHub Action
parent 99ece20cb2
commit 00adb006b4

View file

@ -25,13 +25,13 @@ describe ProcedureExportService do
procedure.reload
end
context 'dossiers' do
it 'should have sheets' do
describe 'sheets' do
it 'should have a sheet for each record type' do
expect(subject.sheets.map(&:name)).to eq(['Dossiers', 'Etablissements', 'Avis'])
end
end
context 'with dossier' do
describe 'Dossiers sheet' do
let!(:dossier) { create(:dossier, :en_instruction, :with_all_champs, :with_individual, procedure: procedure) }
let(:nominal_headers) do
@ -97,14 +97,14 @@ describe ProcedureExportService do
context 'with a procedure routee' do
before { procedure.groupe_instructeurs.create(label: '2') }
let(:routee_header) { nominal_headers.insert(nominal_headers.index('textarea'), 'Groupe instructeur') }
let(:routee_headers) { nominal_headers.insert(nominal_headers.index('textarea'), 'Groupe instructeur') }
it { expect(dossiers_sheet.headers).to match(routee_header) }
it { expect(dossiers_sheet.headers).to match(routee_headers) }
it { expect(dossiers_sheet.data[0][dossiers_sheet.headers.index('Groupe instructeur')]).to eq('défaut') }
end
end
context 'with etablissement' do
describe 'Etablissement sheet' do
let(:procedure) { create(:procedure, :published, :with_all_champs) }
let!(:dossier) { create(:dossier, :en_instruction, :with_all_champs, :with_entreprise, procedure: procedure) }
@ -284,7 +284,7 @@ describe ProcedureExportService do
end
end
context 'with avis' do
describe 'Avis sheet' do
let!(:dossier) { create(:dossier, :en_instruction, :with_all_champs, :with_individual, procedure: procedure) }
let!(:avis) { create(:avis, :with_answer, dossier: dossier) }
@ -305,7 +305,7 @@ describe ProcedureExportService do
end
end
context 'with repetitions' do
describe 'Repetitions sheet' do
let!(:dossiers) do
[
create(:dossier, :en_instruction, :with_all_champs, :with_individual, procedure: procedure),