RUBY-244 issue serializing Time in array
This commit is contained in:
parent
e5338316c8
commit
2b7739a257
Binary file not shown.
|
@ -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 );
|
||||
|
||||
|
|
|
@ -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?
|
||||
|
|
Loading…
Reference in New Issue