diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2019-03-28 22:05:27 +0300 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2019-04-01 21:17:40 +0300 |
commit | 8c5b3d030210cc2659107ec2633a496165470125 (patch) | |
tree | 54e1a98cb3c747715e5047de5051ced536740328 /spec/lib/gitlab/encoding_helper_spec.rb | |
parent | 57cba4d1e9e9964359a5c55bca6558db0d511d98 (diff) |
Allow streaming io objects into Gitaly
This allows us to set the encoding of an IO passed without reading it
into memory.
This is useful if we want to stream files into Gitaly. Like we do when
uploading a new file to the repository.
Diffstat (limited to 'spec/lib/gitlab/encoding_helper_spec.rb')
-rw-r--r-- | spec/lib/gitlab/encoding_helper_spec.rb | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/spec/lib/gitlab/encoding_helper_spec.rb b/spec/lib/gitlab/encoding_helper_spec.rb index 429816efec3..88ea98eb1e1 100644 --- a/spec/lib/gitlab/encoding_helper_spec.rb +++ b/spec/lib/gitlab/encoding_helper_spec.rb @@ -189,14 +189,23 @@ describe Gitlab::EncodingHelper do end end - describe '#binary_stringio' do + describe '#binary_io' do it 'does not mutate the original string encoding' do test = 'my-test' - io_stream = ext_class.binary_stringio(test) + io_stream = ext_class.binary_io(test) expect(io_stream.external_encoding.name).to eq('ASCII-8BIT') expect(test.encoding.name).to eq('UTF-8') end + + it 'returns a copy of the IO with the correct encoding' do + test = fixture_file_upload('spec/fixtures/doc_sample.txt').to_io + + io_stream = ext_class.binary_io(test) + + expect(io_stream.external_encoding.name).to eq('ASCII-8BIT') + expect(test).not_to eq(io_stream) + end end end |