Commit d391f743 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'fix-trace-reader-encoding' into 'master'

Make sure TraceReader uses Encoding.default_external

Closes #27052

See merge request !8801
parents 5d8e9bd5 050103f2
...@@ -42,6 +42,7 @@ module Gitlab ...@@ -42,6 +42,7 @@ module Gitlab
end end
chunks.join.lines.last(max_lines).join chunks.join.lines.last(max_lines).join
.force_encoding(Encoding.default_external)
end end
end end
end end
......
...@@ -11,13 +11,25 @@ describe Gitlab::Ci::TraceReader do ...@@ -11,13 +11,25 @@ describe Gitlab::Ci::TraceReader do
last_lines = random_lines last_lines = random_lines
expected = lines.last(last_lines).join expected = lines.last(last_lines).join
result = subject.read(last_lines: last_lines)
expect(subject.read(last_lines: last_lines)).to eq(expected) expect(result).to eq(expected)
expect(result.encoding).to eq(Encoding.default_external)
end end
end end
it 'returns everything if trying to get too many lines' do it 'returns everything if trying to get too many lines' do
expect(build_subject.read(last_lines: lines.size * 2)).to eq(lines.join) result = build_subject.read(last_lines: lines.size * 2)
expect(result).to eq(lines.join)
expect(result.encoding).to eq(Encoding.default_external)
end
it 'returns all contents if last_lines is not specified' do
result = build_subject.read
expect(result).to eq(lines.join)
expect(result.encoding).to eq(Encoding.default_external)
end end
it 'raises an error if not passing an integer for last_lines' do it 'raises an error if not passing an integer for last_lines' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment