From b75f2125de643e5f95d594bc141500db8e3ca95a Mon Sep 17 00:00:00 2001 From: Eric Leroy-Terquem Date: Mon, 14 Oct 2024 14:52:44 +0200 Subject: [PATCH] refactor(import component): remove path duplication --- app/components/procedure/import_component.rb | 8 ++------ .../procedure/import_component/import_component.html.haml | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/app/components/procedure/import_component.rb b/app/components/procedure/import_component.rb index f8917e1a1..0638203ac 100644 --- a/app/components/procedure/import_component.rb +++ b/app/components/procedure/import_component.rb @@ -9,7 +9,7 @@ class Procedure::ImportComponent < ApplicationComponent @procedure.routing_enabled? ? 'groupes' : 'instructeurs' end - def template_url + def template_file if @procedure.routing_enabled? '/csv/import-groupe-test.csv' else @@ -32,10 +32,6 @@ class Procedure::ImportComponent < ApplicationComponent end def template_path - if @procedure.routing_enabled? - Rails.public_path.join('csv/import-groupe-test.csv') - else - Rails.public_path.join('csv/import-instructeurs-test.csv') - end + Rails.public_path.join(template_file.delete_prefix('/')) end end diff --git a/app/components/procedure/import_component/import_component.html.haml b/app/components/procedure/import_component/import_component.html.haml index 85eb3ffbf..97029f009 100644 --- a/app/components/procedure/import_component/import_component.html.haml +++ b/app/components/procedure/import_component/import_component.html.haml @@ -12,7 +12,7 @@ %label.fr-label.font-weight-bold = t('.csv_import.file_to_import') .fr-download - = link_to template_url, {class: "fr-download__link", download: ''} do + = link_to template_file, {class: "fr-download__link", download: ''} do = t('.csv_import.download_template') %span.fr-download__detail = template_detail