fix(groupe_instructeurs): can parse a monocolumn csv file
This commit is contained in:
parent
e87bb24872
commit
3aa7793ed3
2 changed files with 12 additions and 1 deletions
|
@ -4,7 +4,7 @@ require 'csv'
|
||||||
module ACSV
|
module ACSV
|
||||||
class CSV < ::CSV
|
class CSV < ::CSV
|
||||||
def self.new_for_ruby3(data, options = {})
|
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
|
# 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/)
|
# (https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/)
|
||||||
# instead of
|
# instead of
|
||||||
|
|
|
@ -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") }
|
it { expect(flash.alert).to eq("Import terminé. Cependant les emails suivants ne sont pas pris en compte: kara") }
|
||||||
end
|
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 <a href=\"/csv/#{I18n.locale}/import-groupe-test.csv\">suivant ce modèle</a>") }
|
||||||
|
end
|
||||||
|
|
||||||
context 'when the file content type is application/vnd.ms-excel' do
|
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") }
|
let(:csv_file) { fixture_file_upload('spec/fixtures/files/groupe_avec_caracteres_speciaux.csv', "application/vnd.ms-excel") }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue