Skip to content

Commit 17d2208

Browse files
authored
Add a test to ensure CSV files are converted to UTF-8 (#3482)
This adds a test to the `CSVParser` class to ensure that the input data is parsed in whatever encoding it is provided in and then converted to UTF-8 for manipulation and storage in the database. Currently we're seeing an issue in production which will be fixed in 04ecafb but hasn't been deployed yet. This adds a test to ensure that we don't introduced any regressions in future releases.
2 parents f0b0f0a + 1dc7116 commit 17d2208

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

spec/lib/csv_parser_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,15 @@
3131
expect(row[:header].value).to eq("value")
3232
end
3333
end
34+
35+
context "with input data in Windows-1252 encoding" do
36+
let(:data) { "header\nvalue with \x92 character".b }
37+
38+
it "detects the encoding and converts to UTF-8" do
39+
row = table.first
40+
41+
expect(row[:header].value.encoding).to eq(Encoding::UTF_8)
42+
expect(row[:header].value).to eq("value with ’ character")
43+
end
44+
end
3445
end

0 commit comments

Comments
 (0)