Skip to content
Browse files

Specing legacy connections types.

  • Loading branch information...
1 parent abf9ada commit a85bf44ce5d0988a9cecf95e0be1762a0ed4d72a @jpmedforth jpmedforth committed Jul 6, 2011
View
10 lib/devise_imap_authenticatable/adapter.rb
@@ -17,12 +17,16 @@ def valid_credentials?(username, password)
end
def new_connection
- if Net::IMAP::VERSION >= "1.1.0"
- Net::IMAP.new ::Devise.imap_host, :port => ::Devise.imap_port, :ssl => ::Devise.imap_ssl
- else
+ if previous_version?
Net::IMAP.new ::Devise.imap_host, ::Devise.imap_port, ::Devise.imap_ssl
+ else
+ Net::IMAP.new ::Devise.imap_host, :port => ::Devise.imap_port, :ssl => ::Devise.imap_ssl
end
end
+ def previous_version?
+ Net::IMAP::VERSION < "1.1.0"
+ end
+
end
end
View
9 spec/devise_imap_authenticatable/adapter_spec.rb
@@ -5,14 +5,21 @@
@imap_connection = mock('ImapConnection')
@imap_connection.stub!(:authenticate).and_return(true)
@imap_connection.stub!(:disconnect).and_return(true)
+ Devise::ImapAdapter.stub!(:previous_version?).and_return(false)
end
describe 'valid_credentials?' do
before do
Net::IMAP.stub!(:new).and_return(@imap_connection)
end
- it 'should create a connection to the lap server' do
+ it 'should create a connection to the lap server (older versions)' do
+ Net::IMAP.should_receive(:new).with('localhost', :port => 143, :ssl => false)
+ described_class.valid_credentials?('email@here.com', 'password')
+ end
+
+ it 'should create a connection to the lap server (older versions)' do
+ Devise::ImapAdapter.stub!(:previous_version?).and_return(true)
Net::IMAP.should_receive(:new).with('localhost', 143, false)
described_class.valid_credentials?('email@here.com', 'password')
end
View
0 spec/devise_imap_authenticatable/model_spec.rb
No changes.

0 comments on commit a85bf44

Please sign in to comment.
Something went wrong with that request. Please try again.