RUBY-244 issue serializing Time in array

This commit is contained in:
Kyle Banker 2011-03-04 16:51:12 -05:00
parent e5338316c8
commit 2b7739a257
3 changed files with 10 additions and 1 deletions

Binary file not shown.

View File

@ -281,6 +281,9 @@ public class RubyBSONEncoder extends BSONEncoder {
else if ( val instanceof Iterable)
putIterable( name , (Iterable)val );
else if ( val instanceof Date )
putDate( name , ((Date)val).getTime() );
else if ( val instanceof byte[] )
putBinary( name , (byte[])val );

View File

@ -246,8 +246,14 @@ class BSONTest < Test::Unit::TestCase
assert_in_delta doc['date'], doc2['date'], 0.001
end
def test_date_in_array
doc = {'date' => [Time.now.utc]}
bson = @encoder.serialize(doc)
doc2 = @encoder.deserialize(bson)
end
def test_date_returns_as_utc
doc = {'date' => Time.now}
doc = {'date' => Time.now.utc}
bson = @encoder.serialize(doc)
doc2 = @encoder.deserialize(bson)
assert doc2['date'].utc?