diff options
author | bogdanvlviv <bogdanvlviv@gmail.com> | 2018-03-31 18:16:32 +0300 |
---|---|---|
committer | bogdanvlviv <bogdanvlviv@gmail.com> | 2018-03-31 18:20:46 +0300 |
commit | 4e68b159d5696ca58c015a790ef3ceacb90b27c1 (patch) | |
tree | b08452ca48f359ed55c9e56b0f294966c8134b3a /activesupport/test/core_ext/date_and_time_behavior.rb | |
parent | b1a0ab179f23888eaadacd8292cbcec49ab06fdf (diff) | |
download | rails-4e68b159d5696ca58c015a790ef3ceacb90b27c1.tar.gz rails-4e68b159d5696ca58c015a790ef3ceacb90b27c1.tar.bz2 rails-4e68b159d5696ca58c015a790ef3ceacb90b27c1.zip |
Move implementation of `before?` and `after?` to `DateAndTime::Calculations`
This prevents duplication of code.
Prevent duplication of tests by moving them to `DateAndTimeBehavior`.
Related to #32185.
Diffstat (limited to 'activesupport/test/core_ext/date_and_time_behavior.rb')
-rw-r--r-- | activesupport/test/core_ext/date_and_time_behavior.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/date_and_time_behavior.rb b/activesupport/test/core_ext/date_and_time_behavior.rb index 1422f135a8..b77ea22701 100644 --- a/activesupport/test/core_ext/date_and_time_behavior.rb +++ b/activesupport/test/core_ext/date_and_time_behavior.rb @@ -385,6 +385,18 @@ module DateAndTimeBehavior assert_predicate date_time_init(2015, 1, 5, 15, 15, 10), :on_weekday? end + def test_before + assert_equal false, date_time_init(2017, 3, 6, 12, 0, 0).before?(date_time_init(2017, 3, 5, 12, 0, 0)) + assert_equal false, date_time_init(2017, 3, 6, 12, 0, 0).before?(date_time_init(2017, 3, 6, 12, 0, 0)) + assert_equal true, date_time_init(2017, 3, 6, 12, 0, 0).before?(date_time_init(2017, 3, 7, 12, 0, 0)) + end + + def test_after + assert_equal true, date_time_init(2017, 3, 6, 12, 0, 0).after?(date_time_init(2017, 3, 5, 12, 0, 0)) + assert_equal false, date_time_init(2017, 3, 6, 12, 0, 0).after?(date_time_init(2017, 3, 6, 12, 0, 0)) + assert_equal false, date_time_init(2017, 3, 6, 12, 0, 0).after?(date_time_init(2017, 3, 7, 12, 0, 0)) + end + def with_bw_default(bw = :monday) old_bw = Date.beginning_of_week Date.beginning_of_week = bw |