Permalink
Browse files

Fix UID FETCH.

Previously the client was listening to responses prefixed with
"UID FETCH", though in reality responses to UID FETCH commands are only
prefixed with "FETCH".
  • Loading branch information...
1 parent 612502a commit 728f3bbfd8d4bdb6054bb4c7ddd8bb33048b8462 @ConradIrwin ConradIrwin committed Apr 3, 2012
Showing with 25 additions and 3 deletions.
  1. +1 −1 em-imap.gemspec
  2. +2 −2 lib/em-imap/client.rb
  3. +22 −0 spec/client_spec.rb
View
@@ -1,6 +1,6 @@
Gem::Specification.new do |gem|
gem.name = 'em-imap'
- gem.version = '0.2'
+ gem.version = '0.2.1'
gem.summary = 'An EventMachine based IMAP client.'
gem.description = "Allows you to connect to an IMAP4rev1 server in a non-blocking fashion."
@@ -310,7 +310,7 @@ def fetch(seq, attr="FULL")
# The same as fetch, but keyed of UIDs instead of sequence numbers.
#
def uid_fetch(seq, attr="FULL")
- fetch_internal("UID", "FETCH", seq, attr)
+ fetch_internal("UID FETCH", seq, attr)
end
# Update the flags on a message.
@@ -489,7 +489,7 @@ def fetch_internal(cmd, set, attr)
set = Net::IMAP::MessageSet.new(set)
- multi_data_response(cmd, set, attr).transform do |untagged_responses|
+ collect_untagged_responses('FETCH', cmd, set, attr).transform do |untagged_responses|
untagged_responses.map(&:data)
end
end
View
@@ -161,6 +161,28 @@
@connection.receive_data "RUBY0002 OK Success\r\n"
end
end
+
+ describe "uid_fetch" do
+ before :each do
+ @connection.should_receive(:send_data).with("RUBY0001 LOGIN conrad password\r\n")
+ @client.login('conrad', 'password')
+ @connection.receive_data "RUBY0001 OK conrad authenticated\r\n"
+ @connection.should_receive(:send_data).with("RUBY0002 SELECT Inbox\r\n")
+ @client.select('Inbox')
+ @connection.receive_data "RUBY0002 OK Inbox selected. (Success)\r\n"
+ end
+
+ it "should succeed" do
+ a = nil
+ @connection.should_receive(:send_data).with("RUBY0003 UID FETCH 631 ALL\r\n")
+ @client.uid_fetch(631, 'ALL').callback{ |r| a = r }
+ @connection.receive_data "* 1 FETCH (UID 631 ENVELOPE (\"Tue, 21 Feb 2012 03:48:02 +0000\" \"Wiktionary Word of the Day is down\" ((\"Robbie Pamely\" NIL \"rpamely\" \"gmail.com\")) ((\"Robbie Pamely\" NIL \"rpamely\" \"gmail.com\")) ((\"Robbie Pamely\" NIL \"rpamely\" \"gmail.com\")) ((NIL NIL \"enwikt\" \"toolserver.org\")) NIL NIL NIL \"<CAC1x9c5PL4saRbXYst7B4_dMFJ3iF6C_ux4TArWjzNkrOttBug@mail.gmail.com>\") FLAGS (\\Flagged \\Seen) INTERNALDATE \"21-Feb-2012 03:48:30 +0000\" RFC822.SIZE 5957)\r\n"
+ @connection.receive_data "RUBY0003 OK Success\r\n"
+
+ a.size.should == 1
+ a.first.attr['ENVELOPE'].from.first.name.should == "Robbie Pamely"
+ end
+ end
end
describe "multi-command concurrency" do

0 comments on commit 728f3bb

Please sign in to comment.