1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

net/imap: Net::IMAP#disconnect need not do anything if already disconnected

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58663 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
shugo 2017-05-11 07:56:52 +00:00
parent cb302650a0
commit cea73b2df9
2 changed files with 28 additions and 0 deletions

View file

@ -325,6 +325,7 @@ module Net
# Disconnects from the server.
def disconnect
return if disconnected?
begin
begin
# try to call SSL::SSLSocket#io.

View file

@ -526,6 +526,33 @@ class IMAPTest < Test::Unit::TestCase
end
end
def test_disconnect
server = create_tcp_server
port = server.addr[1]
@threads << Thread.start do
sock = server.accept
begin
sock.print("* OK test server\r\n")
sock.gets
sock.print("* BYE terminating connection\r\n")
sock.print("RUBY0001 OK LOGOUT completed\r\n")
ensure
sock.close
server.close
end
end
begin
imap = Net::IMAP.new(SERVER_ADDR, :port => port)
imap.logout
imap.disconnect
assert_equal(true, imap.disconnected?)
imap.disconnect
assert_equal(true, imap.disconnected?)
ensure
imap.disconnect if imap && !imap.disconnected?
end
end
private
def imaps_test