test/unit/test_support.rb in mongo_mapper-unstable-2010.2.27 vs test/unit/test_support.rb in mongo_mapper-unstable-2010.2.28
- old
+ new
@@ -76,11 +76,11 @@
end
end
context "Date#to_mongo" do
should "be time if string" do
- date = Date.to_mongo('10/1/2009')
+ date = Date.to_mongo('2009-10-01')
date.should == Time.utc(2009, 10, 1)
date.should == date
date.month.should == 10
date.day.should == 1
date.year.should == 2009
@@ -274,12 +274,16 @@
end
end
end
context "Time#to_mongo without Time.zone" do
+ setup do
+ Time.zone = nil
+ end
+
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
+ Time.to_mongo('2000-01-01 01:01:01.123456').to_f.should == Time.local(2000, 1, 1, 1, 1, 1, 123000).utc.to_f
end
should "be time in utc if time" do
Time.to_mongo(Time.local(2009, 8, 15, 0, 0, 0)).zone.should == 'UTC'
end
@@ -294,17 +298,17 @@
end
context "Time#to_mongo with Time.zone" do
should "be time to milliseconds if time" do
Time.zone = 'Hawaii'
- Time.to_mongo(Time.zone.local(2009, 8, 15, 14, 0, 0, 123456)).should == Time.utc(2009, 8, 16, 0, 0, 0, 123000)
+ Time.to_mongo(Time.zone.local(2009, 8, 15, 14, 0, 0, 123456)).to_f.should == Time.utc(2009, 8, 16, 0, 0, 0, 123000).to_f
Time.zone = nil
end
should "be time to milliseconds if string" do
Time.zone = 'Hawaii'
- Time.to_mongo('2009-08-15 14:00:00.123456').should == Time.utc(2009, 8, 16, 0, 0, 0, 123000)
+ Time.to_mongo('2009-08-15 14:00:00.123456').to_f.should == Time.utc(2009, 8, 16, 0, 0, 0, 123000).to_f
Time.zone = nil
end
should "be nil if blank string" do
Time.zone = 'Hawaii'
@@ -357,6 +361,6 @@
should "support ruby driver syntax also" do
id = Mongo::ObjectID.new
id.original_to_json.should == %Q({"$oid": "#{id}"})
end
end
-end
\ No newline at end of file
+end