Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix legacy mongo class names, that are in deprecation as of 1.8.0.

mongodb/mongo-ruby-driver@d356355
Mongo::Connection -> Mongo::MongoClient
Mongo::ReplSetConnection -> Mongo::MongoReplicaSetClient
  • Loading branch information...
commit 8d1f3fd920b30e0e5a5f1b5d6d5fe50f00b65132 1 parent 12c131a
Blaž Hrastnik authored cheald committed
View
8 lib/mongo_mapper/connection.rb
@@ -10,7 +10,7 @@ module Connection
# @api public
def connection
- @@connection ||= Mongo::Connection.new
+ @@connection ||= Mongo::MongoClient.new
end
# @api public
@@ -75,12 +75,12 @@ def connect(environment, options={})
MongoMapper.connection = if env['hosts']
if env['hosts'].first.is_a?(String)
- Mongo::ReplSetConnection.new( env['hosts'], options )
+ Mongo::MongoReplicaSetClient.new( env['hosts'], options )
else
- Mongo::ReplSetConnection.new( *env['hosts'].push(options) )
+ Mongo::MongoReplicaSetClient.new( *env['hosts'].push(options) )
end
else
- Mongo::Connection.new(env['host'], env['port'], options)
+ Mongo::MongoClient.new(env['host'], env['port'], options)
end
MongoMapper.database = env['database']
View
2  test/functional/test_logger.rb
@@ -5,7 +5,7 @@ class LoggerTest < Test::Unit::TestCase
setup do
@output = StringIO.new
@logger = Logger.new(@output)
- MongoMapper.connection = Mongo::Connection.new('127.0.0.1', 27017, :logger => @logger)
+ MongoMapper.connection = Mongo::MongoClient.new('127.0.0.1', 27017, :logger => @logger)
end
should "be able to get access to that logger" do
View
2  test/functional/test_sci.rb
@@ -35,7 +35,7 @@ class ::DocGrandGrandSon < ::DocGrandSon; end
should "use the same connection in the subclass" do
parent_class = Class.new do
include MongoMapper::Document
- connection Mongo::Connection.new
+ connection Mongo::MongoClient.new
end
child_class = Class.new(parent_class) do
View
2  test/test_helper.rb
@@ -88,6 +88,6 @@ def drop_indexes(klass)
FileUtils.mkdir_p(log_dir) unless File.exist?(log_dir)
logger = Logger.new(log_dir + '/test.log')
-MongoMapper.connection = Mongo::Connection.new('127.0.0.1', 27017, :logger => logger)
+MongoMapper.connection = Mongo::MongoClient.new('127.0.0.1', 27017, :logger => logger)
MongoMapper.database = "test"
MongoMapper.database.collections.each { |c| c.drop_indexes }
View
4 test/unit/test_document.rb
@@ -21,11 +21,11 @@ class DocumentTest < Test::Unit::TestCase
end
should "have a connection" do
- @document.connection.should be_instance_of(Mongo::Connection)
+ @document.connection.should be_instance_of(Mongo::MongoClient)
end
should "allow setting different connection without affecting the default" do
- conn = Mongo::Connection.new
+ conn = Mongo::MongoClient.new
@document.connection conn
@document.connection.should == conn
@document.connection.should_not == MongoMapper.connection
View
24 test/unit/test_mongo_mapper.rb
@@ -4,14 +4,14 @@ class Address; end
class MongoMapperTest < Test::Unit::TestCase
should "be able to write and read connection" do
- conn = Mongo::Connection.new
+ conn = Mongo::MongoClient.new
MongoMapper.connection = conn
MongoMapper.connection.should == conn
end
should "default connection to new mongo ruby driver" do
MongoMapper.connection = nil
- MongoMapper.connection.should be_instance_of(Mongo::Connection)
+ MongoMapper.connection.should be_instance_of(Mongo::MongoClient)
end
should "be able to write and read default database" do
@@ -40,7 +40,7 @@ class MongoMapperTest < Test::Unit::TestCase
MongoMapper.config = {
'development' => {'host' => '127.0.0.1', 'port' => 27017, 'database' => 'test'}
}
- Mongo::Connection.expects(:new).with('127.0.0.1', 27017, {})
+ Mongo::MongoClient.expects(:new).with('127.0.0.1', 27017, {})
MongoMapper.expects(:database=).with('test')
Mongo::DB.any_instance.expects(:authenticate).never
MongoMapper.connect('development')
@@ -50,7 +50,7 @@ class MongoMapperTest < Test::Unit::TestCase
MongoMapper.config = {
'development' => {'uri' => 'mongodb://127.0.0.1:27017/test'}
}
- Mongo::Connection.expects(:new).with('127.0.0.1', 27017, {})
+ Mongo::MongoClient.expects(:new).with('127.0.0.1', 27017, {})
MongoMapper.expects(:database=).with('test')
Mongo::DB.any_instance.expects(:authenticate).never
MongoMapper.connect('development')
@@ -60,7 +60,7 @@ class MongoMapperTest < Test::Unit::TestCase
MongoMapper.config = {
'development' => {'host' => '127.0.0.1', 'port' => 27017, 'database' => 'test'}
}
- Mongo::Connection.expects(:new).with('127.0.0.1', 27017, {})
+ Mongo::MongoClient.expects(:new).with('127.0.0.1', 27017, {})
MongoMapper.expects(:database=).with('test')
Mongo::DB.any_instance.expects(:authenticate).never
MongoMapper.connect(:development)
@@ -71,7 +71,7 @@ class MongoMapperTest < Test::Unit::TestCase
'development' => {'host' => '127.0.0.1', 'port' => 27017, 'database' => 'test'}
}
connection, logger = mock('connection'), mock('logger')
- Mongo::Connection.expects(:new).with('127.0.0.1', 27017, :logger => logger)
+ Mongo::MongoClient.expects(:new).with('127.0.0.1', 27017, :logger => logger)
MongoMapper.connect('development', :logger => logger)
end
@@ -80,7 +80,7 @@ class MongoMapperTest < Test::Unit::TestCase
'development' => {'host' => '127.0.0.1', 'port' => 27017, 'database' => 'test', 'ssl' => true}
}
connection, logger = mock('connection'), mock('logger')
- Mongo::Connection.expects(:new).with('127.0.0.1', 27017, :logger => logger, :ssl => true)
+ Mongo::MongoClient.expects(:new).with('127.0.0.1', 27017, :logger => logger, :ssl => true)
MongoMapper.connect('development', :logger => logger)
end
@@ -89,7 +89,7 @@ class MongoMapperTest < Test::Unit::TestCase
'development' => {'host' => '127.0.0.1', 'port' => 27017, 'database' => 'test', 'ssl' => false}
}
connection, logger = mock('connection'), mock('logger')
- Mongo::Connection.expects(:new).with('127.0.0.1', 27017, :logger => logger, :ssl => false)
+ Mongo::MongoClient.expects(:new).with('127.0.0.1', 27017, :logger => logger, :ssl => false)
MongoMapper.connect('development', :logger => logger)
end
@@ -98,7 +98,7 @@ class MongoMapperTest < Test::Unit::TestCase
'development' => {'host' => '192.168.1.1', 'port' => 2222, 'database' => 'test', 'options' => {'safe' => true}}
}
connection, logger = mock('connection'), mock('logger')
- Mongo::Connection.expects(:new).with('192.168.1.1', 2222, :logger => logger, :safe => true)
+ Mongo::MongoClient.expects(:new).with('192.168.1.1', 2222, :logger => logger, :safe => true)
MongoMapper.connect('development', :logger => logger)
end
@@ -107,7 +107,7 @@ class MongoMapperTest < Test::Unit::TestCase
'development' => {'uri' => 'mongodb://127.0.0.1:27017/test'}
}
connection, logger = mock('connection'), mock('logger')
- Mongo::Connection.expects(:new).with('127.0.0.1', 27017, :logger => logger)
+ Mongo::MongoClient.expects(:new).with('127.0.0.1', 27017, :logger => logger)
MongoMapper.connect('development', :logger => logger)
end
@@ -142,7 +142,7 @@ class MongoMapperTest < Test::Unit::TestCase
}
}
- Mongo::ReplSetConnection.expects(:new).with( ['127.0.0.1', 27017], ['localhost', 27017], {'read_secondary' => true} )
+ Mongo::MongoReplicaSetClient.expects(:new).with( ['127.0.0.1', 27017], ['localhost', 27017], {'read_secondary' => true} )
MongoMapper.expects(:database=).with('test')
Mongo::DB.any_instance.expects(:authenticate).never
MongoMapper.connect('development', 'read_secondary' => true)
@@ -156,7 +156,7 @@ class MongoMapperTest < Test::Unit::TestCase
}
}
- Mongo::ReplSetConnection.expects(:new).with( ['127.0.0.1:27017', 'localhost:27017'], {'read_secondary' => true} )
+ Mongo::MongoReplicaSetClient.expects(:new).with( ['127.0.0.1:27017', 'localhost:27017'], {'read_secondary' => true} )
MongoMapper.expects(:database=).with('test')
Mongo::DB.any_instance.expects(:authenticate).never
MongoMapper.connect('development', 'read_secondary' => true)
Please sign in to comment.
Something went wrong with that request. Please try again.