Permalink
Browse files

Fail the connection on an unexpected continuation.

  • Loading branch information...
1 parent 7b68769 commit 06963c1d959d758809dd2304c8501c7ec901c197 @ConradIrwin ConradIrwin committed Jul 2, 2011
Showing with 11 additions and 2 deletions.
  1. +6 −2 lib/em-imap/continuation_synchronisation.rb
  2. +5 −0 spec/continuation_synchronisation_spec.rb
View
8 lib/em-imap/continuation_synchronisation.rb
@@ -59,8 +59,12 @@ def await_continuations(&block)
# continuation responses onto the currently awaiting block.
def listen_for_continuation
add_response_handler do |response|
- if awaiting_continuation? && response.is_a?(Net::IMAP::ContinuationRequest)
- @awaiting_continuation.receive_event response
+ if response.is_a?(Net::IMAP::ContinuationRequest)
+ if awaiting_continuation?
+ @awaiting_continuation.receive_event response
+ else
+ fail_all Net::IMAP::ResponseError.new("Unexpected continuation response from server")
+ end
end
end
end
View
5 spec/continuation_synchronisation_spec.rb
@@ -85,4 +85,9 @@
@connection.receive_response response2
a.should == [response1]
end
+
+ it "should fail the connection when an unexpected continuation response is received" do
+ @connection.should_receive(:fail_all).with(an_instance_of(Net::IMAP::ResponseError))
+ @connection.receive_response Net::IMAP::ContinuationRequest.new("hehe")
+ end
end

0 comments on commit 06963c1

Please sign in to comment.