diff --git a/lib/mongo/connection.rb b/lib/mongo/connection.rb index 542dbcb..329f9e6 100644 --- a/lib/mongo/connection.rb +++ b/lib/mongo/connection.rb @@ -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. diff --git a/test/connection_test.rb b/test/connection_test.rb index f942b8e..0e977b3 100644 --- a/test/connection_test.rb +++ b/test/connection_test.rb @@ -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)