test/unit/test_support.rb in mongo_mapper-unstable-2010.1.6 vs test/unit/test_support.rb in mongo_mapper-unstable-2010.1.12

- old
+ new

@@ -88,10 +88,14 @@ should "be time if date" do Date.to_mongo(Date.new(2009, 10, 1)).should == Time.utc(2009, 10, 1) end + should "be date if time" do + Date.to_mongo(Time.parse("2009-10-1T12:30:00")).should == Time.utc(2009, 10, 1) + end + should "be nil if bogus string" do Date.to_mongo('jdsafop874').should be_nil end should "be nil if empty string" do @@ -262,12 +266,12 @@ String.from_mongo('').should == '' end end context "Time#to_mongo without Time.zone" do - should "be time if string" do - Time.to_mongo('2000-01-01 01:01:01.123456').should == Time.local(2000, 1, 1, 1, 1, 1, 123456).utc + should "be time to milliseconds if string" do + Time.to_mongo('2000-01-01 01:01:01.123456').should == Time.local(2000, 1, 1, 1, 1, 1, 123000).utc end should "be time in utc if time" do Time.to_mongo(Time.local(2009, 8, 15, 0, 0, 0)).zone.should == 'UTC' end @@ -280,18 +284,18 @@ Time.to_mongo(nil).should be_nil end end context "Time#to_mongo with Time.zone" do - should "be time if time" do + should "be time to milliseconds if time" do Time.zone = 'Hawaii' - Time.to_mongo(Time.zone.local(2009, 8, 15, 14, 0, 0)).should == Time.utc(2009, 8, 16, 0, 0, 0) + Time.to_mongo(Time.zone.local(2009, 8, 15, 14, 0, 0, 123456)).should == Time.utc(2009, 8, 16, 0, 0, 0, 123000) Time.zone = nil end - should "be time if string" do + should "be time to milliseconds if string" do Time.zone = 'Hawaii' - Time.to_mongo('2009-08-15 14:00:00').should == Time.utc(2009, 8, 16, 0, 0, 0) + Time.to_mongo('2009-08-15 14:00:00.123456').should == Time.utc(2009, 8, 16, 0, 0, 0, 123000) Time.zone = nil end should "be nil if blank string" do Time.zone = 'Hawaii' \ No newline at end of file