diff options
author | Nick Johnstone <ncwjohnstone@gmail.com> | 2017-02-22 20:45:48 +1300 |
---|---|---|
committer | Jeremy Daer <jeremydaer@gmail.com> | 2017-02-26 01:18:51 -0700 |
commit | 2d84a6bc74fbe9d9b97bf7d63ec6f27418d9c3a6 (patch) | |
tree | 2ff0b32a5bc0532330d02af563eab3e9bd484461 /activesupport/CHANGELOG.md | |
parent | 8fc71d1eb4055912f0b84956c2c4fab62d0d7793 (diff) | |
download | rails-2d84a6bc74fbe9d9b97bf7d63ec6f27418d9c3a6.tar.gz rails-2d84a6bc74fbe9d9b97bf7d63ec6f27418d9c3a6.tar.bz2 rails-2d84a6bc74fbe9d9b97bf7d63ec6f27418d9c3a6.zip |
Add Duration#before and #after as aliases for #ago and #since
It's common in test cases at my job to have code like this:
let(:today) { customer_start_date + 2.weeks }
let(:earlier_date) { today - 5.days }
With this change, we can instead write
let(:today) { 2.weeks.after(customer_start_date) }
let(:earlier_date) { 5.days.before(today) }
Closes #27721
Diffstat (limited to 'activesupport/CHANGELOG.md')
-rw-r--r-- | activesupport/CHANGELOG.md | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md index 2f08d8bc82..0614cdaabd 100644 --- a/activesupport/CHANGELOG.md +++ b/activesupport/CHANGELOG.md @@ -1,3 +1,19 @@ +* Add `ActiveSupport::Duration#before` and `#after` as aliases for `#until` and `#since` + + These read more like English and require less mental gymnastics to read and write. + + Before: + + 2.weeks.since(customer_start_date) + 5.days.until(today) + + After: + + 2.weeks.after(customer_start_date) + 5.days.before(today) + + *Nick Johnstone* + * Soft-deprecated the top-level `HashWithIndifferentAccess` constant. `ActiveSupport::HashWithIndifferentAccess` should be used instead. |