RUBY-191 fix to pass options to new db with Connection#db

This commit is contained in:
Kyle Banker 2010-10-21 13:27:57 -04:00
parent afe8fe3167
commit a905c3f1f2
2 changed files with 8 additions and 1 deletions

View File

@ -293,7 +293,7 @@ module Mongo
#
# @core databases db-instance_method
def db(db_name, options={})
DB.new(db_name, self)
DB.new(db_name, self, options)
end
# Shortcut for returning a database. Use DB#db to accept options.

View File

@ -43,6 +43,13 @@ class TestConnection < Test::Unit::TestCase
assert_raise Mongo::InvalidNSName do @mongo.db('te st') end
end
def test_options_passed_to_db
@pk_mock = Object.new
db = @mongo.db('test', :pk => @pk_mock, :strict => true)
assert_equal @pk_mock, db.pk_factory
assert db.strict?
end
def test_database_info
@mongo.drop_database(MONGO_TEST_DB)
@mongo.db(MONGO_TEST_DB).collection('info-test').insert('a' => 1)