diff options
Diffstat (limited to 'app/services/issuable/import_csv')
-rw-r--r-- | app/services/issuable/import_csv/base_service.rb | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/app/services/issuable/import_csv/base_service.rb b/app/services/issuable/import_csv/base_service.rb index bf5f643a51b..5a2665285de 100644 --- a/app/services/issuable/import_csv/base_service.rb +++ b/app/services/issuable/import_csv/base_service.rb @@ -38,20 +38,19 @@ module Issuable def with_csv_lines csv_data = @csv_io.open(&:read).force_encoding(Encoding::UTF_8) - verify_headers!(csv_data) + validate_headers_presence!(csv_data.lines.first) - csv_parsing_params = { + CSV.new( + csv_data, col_sep: detect_col_sep(csv_data.lines.first), headers: true, header_converters: :symbol - } - - CSV.new(csv_data, csv_parsing_params).each.with_index(2) + ).each.with_index(2) end - def verify_headers!(data) - headers = data.lines.first.downcase - return if headers.include?('title') && headers.include?('description') + def validate_headers_presence!(headers) + headers.downcase! if headers + return if headers && headers.include?('title') && headers.include?('description') raise CSV::MalformedCSVError end |