Fix `File#write_buffer` to always return the given `io`
Ref: ef89a62b70
This fixes a regression in 2.4.rc1.
Cherry-picked into 3.0 for consistency.
This commit is contained in:
parent
0c0003cfda
commit
5c6a7c9ad9
|
@ -301,7 +301,7 @@ module Zip
|
||||||
|
|
||||||
# Write buffer write changes to buffer and return
|
# Write buffer write changes to buffer and return
|
||||||
def write_buffer(io = ::StringIO.new)
|
def write_buffer(io = ::StringIO.new)
|
||||||
return unless commit_required?
|
return io unless commit_required?
|
||||||
|
|
||||||
::Zip::OutputStream.write_buffer(io) do |zos|
|
::Zip::OutputStream.write_buffer(io) do |zos|
|
||||||
@cdir.each { |e| e.write_to_zip_output_stream(zos) }
|
@cdir.each { |e| e.write_to_zip_output_stream(zos) }
|
||||||
|
|
|
@ -233,7 +233,7 @@ class ZipFileTest < MiniTest::Test
|
||||||
assert zf.entries.map(&:name).include?('zippedruby1.rb')
|
assert zf.entries.map(&:name).include?('zippedruby1.rb')
|
||||||
|
|
||||||
# Ensure the buffer isn't changed.
|
# Ensure the buffer isn't changed.
|
||||||
zf.write_buffer(string_io)
|
assert_same(string_io, zf.write_buffer(string_io))
|
||||||
assert_equal(data, string_io.string)
|
assert_equal(data, string_io.string)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue