From ab1159581edd4b58e57fd24c2756c2e486d05d54 Mon Sep 17 00:00:00 2001 From: Durran Jordan Date: Sat, 24 Nov 2012 14:43:40 +0100 Subject: [PATCH] Update changelog --- CHANGELOG.md | 3 +++ spec/mongoid/extensions/time_spec.rb | 22 ++++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b96c87a316..c65c048e09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ For instructions on upgrading to newer versions, visit ### Resolved Issues +* \#2575 Prevent end of month times from rounding up since floats are not + precise enough to handle usec. (Steve Valaitis) + * \#2573 Don't use i18n for inspection messages. * \#2571 Remove blank error message from locales. (Jordan Elver) diff --git a/spec/mongoid/extensions/time_spec.rb b/spec/mongoid/extensions/time_spec.rb index a5922784e3..08fd950621 100644 --- a/spec/mongoid/extensions/time_spec.rb +++ b/spec/mongoid/extensions/time_spec.rb @@ -262,10 +262,19 @@ Time.mongoize(time).to_f.round(3).should eq(time.to_f.round(3)) end - it "doesn't round up at end of month" do + it "doesn't round up the hour at end of month" do eom_time_mongoized.hour.should eq(eom_time.utc.hour) + end + + it "doesn't round up the minute" do eom_time_mongoized.min.should eq(eom_time.utc.min) + end + + it "doesn't round up the seconds" do eom_time_mongoized.sec.should eq(eom_time.utc.sec) + end + + it "does not alter seconds" do (eom_time_mongoized.strftime("%11N").to_i / 100.0).round(0).should eq(999999999) end @@ -292,10 +301,19 @@ ) end - it "doesn't round up at end of month" do + it "doesn't round up the hour" do eom_time_mongoized.hour.should eq(eom_time.utc.hour) + end + + it "doesn't round up the minutes" do eom_time_mongoized.min.should eq(eom_time.utc.min) + end + + it "doesn't round up the seconds" do eom_time_mongoized.sec.should eq(eom_time.utc.sec) + end + + it "does not alter the seconds" do (eom_time_mongoized.strftime("%11N").to_i / 100.0).round(0).should eq(999999999) end end