From f850924dc0f9122e09fc091fc271955f5bf0f873 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Mon, 14 Oct 2024 22:23:59 +0200 Subject: [PATCH] remove procedure_presentation from export --- app/components/dossiers/export_link_component.rb | 2 +- app/models/export.rb | 7 +++++-- spec/components/dossiers/export_link_component_spec.rb | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/components/dossiers/export_link_component.rb b/app/components/dossiers/export_link_component.rb index 78a997f71..f3ce43e34 100644 --- a/app/components/dossiers/export_link_component.rb +++ b/app/components/dossiers/export_link_component.rb @@ -30,7 +30,7 @@ class Dossiers::ExportLinkComponent < ApplicationComponent end def export_title(export) - if export.procedure_presentation_id.nil? + if !export.built_from_procedure_presentation? t(".export_title_everything", export_format: export.format) elsif export.tous? t(".export_title", export_format: export.format, count: export.count) diff --git a/app/models/export.rb b/app/models/export.rb index f949bca63..0f35d4bdb 100644 --- a/app/models/export.rb +++ b/app/models/export.rb @@ -94,7 +94,6 @@ class Export < ApplicationRecord create!(**attributes, groupe_instructeurs:, user_profile:, - procedure_presentation:, filtered_columns:, sorted_column:) end @@ -118,7 +117,7 @@ class Export < ApplicationRecord def count return dossiers_count if !dossiers_count.nil? # export generated - return dossiers_for_export.count if procedure_presentation_id.present? + return dossiers_for_export.count if built_from_procedure_presentation? nil end @@ -127,6 +126,10 @@ class Export < ApplicationRecord groupe_instructeurs.first.procedure end + def built_from_procedure_presentation? + sorted_column.present? # hack has we know that procedure_presentation always has a sorted_column + end + private def dossiers_for_export diff --git a/spec/components/dossiers/export_link_component_spec.rb b/spec/components/dossiers/export_link_component_spec.rb index 4aa757b90..f1834c8ca 100644 --- a/spec/components/dossiers/export_link_component_spec.rb +++ b/spec/components/dossiers/export_link_component_spec.rb @@ -36,9 +36,9 @@ RSpec.describe Dossiers::ExportLinkComponent, type: :component do end end - context 'when export is for a presentation' do + context 'when export is from a presentation' do before do - export.update!(procedure_presentation: procedure_presentation) + export.update!(sorted_column: procedure.default_sorted_column) end it 'display the persisted dossiers count' do @@ -48,7 +48,7 @@ RSpec.describe Dossiers::ExportLinkComponent, type: :component do end context "when the export is not available" do - let(:export) { create(:export, :pending, groupe_instructeurs: [groupe_instructeur], procedure_presentation: procedure_presentation, created_at: 10.minutes.ago) } + let(:export) { create(:export, :pending, groupe_instructeurs: [groupe_instructeur], sorted_column: procedure.default_sorted_column, created_at: 10.minutes.ago) } before do create_list(:dossier, 3, :en_construction, procedure: procedure, groupe_instructeur: groupe_instructeur)