File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -1102,6 +1102,20 @@ def close
1102
1102
send_command ( "CLOSE" )
1103
1103
end
1104
1104
1105
+ # Sends an {UNSELECT command [IMAP4rev2
1106
+ # §6.4.2]}[https://www.rfc-editor.org/rfc/rfc9051#section-6.4.2] to free the
1107
+ # session resources for a mailbox and return to the "_authenticated_" state.
1108
+ # This is the same as #close, except that <tt>\\Deleted</tt> messages are
1109
+ # not removed from the mailbox.
1110
+ #
1111
+ # ===== Capabilities
1112
+ #
1113
+ # The server's capabilities must include +UNSELECT+
1114
+ # [RFC3691[https://tools.ietf.org/html/rfc3691]].
1115
+ def unselect
1116
+ send_command ( "UNSELECT" )
1117
+ end
1118
+
1105
1119
# Sends a EXPUNGE command to permanently remove from the currently
1106
1120
# selected mailbox all messages that have the \Deleted flag set.
1107
1121
def expunge
Original file line number Diff line number Diff line change @@ -915,6 +915,27 @@ def test_close
915
915
end
916
916
end
917
917
918
+ def test_unselect
919
+ requests = Queue . new
920
+ port = yields_in_test_server_thread do |sock , gets |
921
+ requests . push ( gets [ ] )
922
+ sock . print ( "RUBY0001 OK UNSELECT completed\r \n " )
923
+ requests . push ( gets [ ] )
924
+ "RUBY0002"
925
+ end
926
+ begin
927
+ imap = Net ::IMAP . new ( server_addr , :port => port )
928
+ resp = imap . unselect
929
+ assert_equal ( [ "RUBY0001" , "UNSELECT" , "" ] , requests . pop )
930
+ assert_equal ( [ Net ::IMAP ::TaggedResponse , "RUBY0001" , "OK" ] ,
931
+ [ resp . class , resp . tag , resp . name ] )
932
+ imap . logout
933
+ assert_equal ( [ "RUBY0002" , "LOGOUT" , "" ] , requests . pop )
934
+ ensure
935
+ imap . disconnect if imap
936
+ end
937
+ end
938
+
918
939
private
919
940
920
941
def imaps_test
You can’t perform that action at this time.
0 commit comments