aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/CHANGELOG.md
diff options
context:
space:
mode:
authorGodfrey Chan <godfreykfc@gmail.com>2013-09-27 12:51:36 -0700
committerGodfrey Chan <godfreykfc@gmail.com>2013-11-26 22:24:19 -0800
commit1f1613604925823be4b15893fbb8f957a38dd0b8 (patch)
treee80aee6332bcd19c5f969151e9f667b919558d5b /activesupport/CHANGELOG.md
parent5fdbec7dd15a8e6edef861899accb8b3b69cc87a (diff)
downloadrails-1f1613604925823be4b15893fbb8f957a38dd0b8.tar.gz
rails-1f1613604925823be4b15893fbb8f957a38dd0b8.tar.bz2
rails-1f1613604925823be4b15893fbb8f957a38dd0b8.zip
Deprecated Numeric#{ago,until,since,from_now}
The user is expected to explicitly convert the value into an AS::Duration, i.e. `5.ago` => `5.seconds.ago` This will help to catch subtle bugs like: def recent?(days = 3) self.created_at >= days.ago end The above code would check if the model is created within the last 3 **seconds**. In the future, `Numeric#{ago,until,since,from_now}` should be removed completely, or throw some sort of errors to indicate there are no implicit conversion from `Numeric` to `AS::Duration`. Also fixed & refactor the test cases for Numeric#{ago,since} and AS::Duration#{ago,since}. The original test case had the assertion flipped and the purpose of the test wasn't very clear.
Diffstat (limited to 'activesupport/CHANGELOG.md')
-rw-r--r--activesupport/CHANGELOG.md17
1 files changed, 17 insertions, 0 deletions
diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md
index 104b5eafa1..d03b1674d4 100644
--- a/activesupport/CHANGELOG.md
+++ b/activesupport/CHANGELOG.md
@@ -1,3 +1,20 @@
+* Deprecated Numeric#{ago,until,since,from_now}, the user is expected to explicitly
+ convert the value into an AS::Duration, i.e. 5.ago => 5.seconds.ago
+
+ This will help to catch subtle bugs like:
+
+ def recent?(days = 3)
+ self.created_at >= days.ago
+ end
+
+ The above code would check if the model is created within the last 3 **seconds**.
+
+ In the future, Numeric#{ago,until,since,from_now} should be removed completely,
+ or throw some sort of errors to indicate there are no implicit conversion from
+ Numeric to AS::Duration.
+
+ *Godfrey Chan*
+
* Add `ActiveSupport::Testing::TimeHelpers#travel` and `#travel_to`. These methods change current
time to the given time or time difference by stubbing `Time.now` and `Date.today` to return the
time or date after the difference calculation, or the time or date that got passed into the