Project

General

Profile

Actions

Defect #28689

closed

csv 1.0.2 gem breaks ImportsControllerTest

Defect #28689: csv 1.0.2 gem breaks ImportsControllerTest

Added by Go MAEDA over 8 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Gems support
Target version:
-
Resolution:
Fixed
Affected version:

Description

This issue is reproducible only on Ruby 2.5 because csv gem is used for Ruby 2.5 only (see r17245). No problem with csv 1.0.1.

$ ruby test/functional/imports_controller_test.rb
Run options: --seed 38551

# Running:

.......F

Failure:
ImportsControllerTest#test_post_settings_with_wrong_encoding_should_display_error [test/functional/imports_controller_test.rb:125]:
<(?-mix:not a valid UTF-8 encoded file)> expected but was
<The file is not a CSV file or does not match the settings below>..
Expected 0 to be >= 1.

bin/rails test test/functional/imports_controller_test.rb:111

Files

28689.diff (1.32 KB) 28689.diff patch Go MAEDA, 2018-05-06 04:43
28689-v2.diff (1.43 KB) 28689-v2.diff patch (also supports Ruby 2.2) Go MAEDA, 2018-05-06 07:31

Related issues 2 (0 open — 2 closed)

Related to Redmine - Feature #27849: Ruby 2.5 supportClosedJean-Philippe LangActions
Related to Redmine - Patch #28112: CsvTest fails due to a regression in Ruby 2.5ClosedGo MAEDAActions

Updated by Go MAEDA over 8 years ago Actions #1

Updated by Go MAEDA over 8 years ago Actions #2

  • Related to Patch #28112: CsvTest fails due to a regression in Ruby 2.5 added

Updated by Go MAEDA over 8 years ago Actions #3

  • Category changed from Ruby support to Gems support

The cause of this issue is the changed behavior of csv gem. csv gem 1.0.2 throws MalformedCSVError instead of ArgumentError if the library find invalid byte sequences in a CSV file. As a result, Redmine displays the error :error_invalid_csv_file_or_settings instead of :error_invalid_file_encoding.

The behavior has changed by this commit.

https://github.com/ruby/csv/commit/88a3471203a3bc83d58ab015e92182ae5d8e0ad0

The current versions of Redmine expect ArgumentError if the parameter and file encoding does not much.

source:tags/3.4.5/app/controllers/imports_controller.rb#L55

Updated by Go MAEDA over 8 years ago Actions #4

The attached patch should fix this issue.
Setting target version to 4.0.0.

Updated by Go MAEDA over 8 years ago Actions #5

Go MAEDA wrote:

The attached patch should fix this issue.

No, csv gem does not support Ruby < 2.3. Redmine 4.0.0 will support Ruby 2.2.2 and later. (#25538).

Updated by Go MAEDA over 8 years ago Actions #6

Here is an updated patch. Tested with Ruby 2.2, 2.3, 2.4, and 2.5.

Updated by Go MAEDA over 8 years ago Actions #7

  • Status changed from New to Closed
  • Target version deleted (4.0.0)
  • Resolution set to Fixed

Committed.

Actions

Also available in: PDF Atom