bug(export): la creation d'une archive avec un filtre different devrait etre effective, ce n'est pas le cas

This commit is contained in:
Martin 2022-10-21 16:53:11 +02:00 committed by mfo
parent cde1aebe5e
commit cf51be85e0

View file

@ -66,6 +66,28 @@ RSpec.describe Export, type: :model do
end
end
describe '.find_or_create_export' do
let!(:procedure) { create(:procedure) }
let!(:gi_1) { create(:groupe_instructeur, procedure: procedure, instructeurs: [create(:instructeur)]) }
let!(:pp) { gi_1.instructeurs.first.procedure_presentation_and_errors_for_procedure_id(procedure.id).first }
before { pp.add_filter('tous', 'self/created_at', '10/12/2021') }
context 'with procedure_presentation having different filters' do
it 'works once' do
expect { Export.find_or_create_export(:zip, [gi_1], time_span_type: Export.time_span_types.fetch(:everything), statut: Export.statuts.fetch(:tous), procedure_presentation: pp) }
.to change { Export.count }.by(1)
end
it 'works once, changes procedure_presentation, recreate a new' do
expect { Export.find_or_create_export(:zip, [gi_1], time_span_type: Export.time_span_types.fetch(:everything), statut: Export.statuts.fetch(:tous), procedure_presentation: pp) }
.to change { Export.count }.by(1)
pp.add_filter('tous', 'self/updated_at', '10/12/2021')
expect { Export.find_or_create_export(:zip, [gi_1], time_span_type: Export.time_span_types.fetch(:everything), statut: Export.statuts.fetch(:tous), procedure_presentation: pp) }
.to change { Export.count }.by(1)
end
end
end
describe '.dossiers_for_export' do
let!(:procedure) { create(:procedure, :published, :with_instructeur) }