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 @@ -796,6 +796,20 @@ def close
796
796
send_command ( "CLOSE" )
797
797
end
798
798
799
+ # Sends an {UNSELECT command [IMAP4rev2
800
+ # §6.4.2]}[https://www.rfc-editor.org/rfc/rfc9051#section-6.4.2] to free the
801
+ # session resources for a mailbox and return to the "_authenticated_" state.
802
+ # This is the same as #close, except that <tt>\\Deleted</tt> messages are
803
+ # not removed from the mailbox.
804
+ #
805
+ # ===== Capabilities
806
+ #
807
+ # The server's capabilities must include +UNSELECT+
808
+ # [RFC3691[https://tools.ietf.org/html/rfc3691]].
809
+ def unselect
810
+ send_command ( "UNSELECT" )
811
+ end
812
+
799
813
# Sends a EXPUNGE command to permanently remove from the currently
800
814
# selected mailbox all messages that have the \Deleted flag set.
801
815
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