diff --git a/config/initializers/acsv.rb b/config/initializers/acsv.rb index 3a24d2032..d099dbe6a 100644 --- a/config/initializers/acsv.rb +++ b/config/initializers/acsv.rb @@ -4,7 +4,7 @@ require 'csv' module ACSV class CSV < ::CSV def self.new_for_ruby3(data, options = {}) - options[:col_sep] ||= ACSV::Detect.separator(data) + options[:col_sep] ||= ACSV::Detect.separator(data) || :auto # because of the Separation of positional and keyword arguments in Ruby 3.0 # (https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/) # instead of diff --git a/spec/controllers/administrateurs/groupe_instructeurs_controller_spec.rb b/spec/controllers/administrateurs/groupe_instructeurs_controller_spec.rb index b3b1f1a2f..7c1693b88 100644 --- a/spec/controllers/administrateurs/groupe_instructeurs_controller_spec.rb +++ b/spec/controllers/administrateurs/groupe_instructeurs_controller_spec.rb @@ -405,6 +405,17 @@ describe Administrateurs::GroupeInstructeursController, type: :controller do it { expect(flash.alert).to eq("Import terminé. Cependant les emails suivants ne sont pas pris en compte: kara") } end + context 'when the csv file has only one column' do + let(:csv_file) { fixture_file_upload('spec/fixtures/files/valid-instructeurs-file.csv', 'text/csv') } + + before { subject } + + it { expect { subject }.not_to raise_error } + it { expect(response.status).to eq(302) } + it { expect(flash.alert).to be_present } + it { expect(flash.alert).to eq("Importation impossible, veuillez importer un csv suivant ce modèle") } + end + context 'when the file content type is application/vnd.ms-excel' do let(:csv_file) { fixture_file_upload('spec/fixtures/files/groupe_avec_caracteres_speciaux.csv', "application/vnd.ms-excel") }