From 4ef032b6f90cc3b31d6639afdb7d2a8d30c67b34 Mon Sep 17 00:00:00 2001 From: Jim Menard Date: Mon, 26 Jan 2009 08:51:27 -0500 Subject: [PATCH] Test using non-ObjectID _id value. --- tests/test_db_api.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/test_db_api.rb b/tests/test_db_api.rb index b3ca83f..46d829f 100644 --- a/tests/test_db_api.rb +++ b/tests/test_db_api.rb @@ -286,6 +286,16 @@ class DBAPITest < Test::Unit::TestCase assert_equal regex, rows[0]['b'] end + def test_non_oid_id + # Note: can't use Time.new because that will include fractional seconds, + # which Mongo does not store. + t = Time.at(1234567890) + @coll << {'_id' => t} + rows = @coll.find({'_id' => t}).to_a + assert_equal 1, rows.length + assert_equal t, rows[0]['_id'] + end + def test_strict assert !@db.strict? @db.strict = true