aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext
diff options
context:
space:
mode:
authorGeorge Claghorn <george.claghorn@gmail.com>2015-01-05 23:06:45 -0500
committerGeorge Claghorn <george.claghorn@gmail.com>2015-01-06 05:43:06 -0500
commitb6d0d0d106b5cd59f8da3f893b29a05bc85ac14e (patch)
treebe2b4a21ebeef87c6a2a5470437a112b685cca4f /activesupport/test/core_ext
parentadf5fc3b3c9b5774c0ad621ac3503d236b8ddd9c (diff)
downloadrails-b6d0d0d106b5cd59f8da3f893b29a05bc85ac14e.tar.gz
rails-b6d0d0d106b5cd59f8da3f893b29a05bc85ac14e.tar.bz2
rails-b6d0d0d106b5cd59f8da3f893b29a05bc85ac14e.zip
Add same_time option to #prev_week and #next_week for Date, Time, and DateTime
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r--activesupport/test/core_ext/date_and_time_behavior.rb15
1 files changed, 15 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 a6a21f8de4..6b6e1a2a4c 100644
--- a/activesupport/test/core_ext/date_and_time_behavior.rb
+++ b/activesupport/test/core_ext/date_and_time_behavior.rb
@@ -115,6 +115,13 @@ module DateAndTimeBehavior
end
end
+ def test_next_week_at_same_time
+ assert_equal date_time_init(2005,2,28,15,15,10), date_time_init(2005,2,22,15,15,10).next_week(:monday, same_time: true)
+ assert_equal date_time_init(2005,3,4,15,15,10), date_time_init(2005,2,22,15,15,10).next_week(:friday, same_time: true)
+ assert_equal date_time_init(2006,10,30,0,0,0), date_time_init(2006,10,23,0,0,0).next_week(:monday, same_time: true)
+ assert_equal date_time_init(2006,11,1,0,0,0), date_time_init(2006,10,23,0,0,0).next_week(:wednesday, same_time: true)
+ end
+
def test_next_weekday_on_wednesday
assert_equal date_time_init(2015,1,8,0,0,0), date_time_init(2015,1,7,0,0,0).next_weekday
assert_equal date_time_init(2015,1,8,15,15,10), date_time_init(2015,1,7,15,15,10).next_weekday
@@ -159,6 +166,14 @@ module DateAndTimeBehavior
end
end
+ def test_prev_week_at_same_time
+ assert_equal date_time_init(2005,2,21,15,15,10), date_time_init(2005,3,1,15,15,10).prev_week(:monday, same_time: true)
+ assert_equal date_time_init(2005,2,22,15,15,10), date_time_init(2005,3,1,15,15,10).prev_week(:tuesday, same_time: true)
+ assert_equal date_time_init(2005,2,25,15,15,10), date_time_init(2005,3,1,15,15,10).prev_week(:friday, same_time: true)
+ assert_equal date_time_init(2006,10,30,0,0,0), date_time_init(2006,11,6,0,0,0).prev_week(:monday, same_time: true)
+ assert_equal date_time_init(2006,11,15,0,0,0), date_time_init(2006,11,23,0,0,0).prev_week(:wednesday, same_time: true)
+ end
+
def test_prev_weekday_on_wednesday
assert_equal date_time_init(2015,1,6,0,0,0), date_time_init(2015,1,7,0,0,0).prev_weekday
assert_equal date_time_init(2015,1,6,15,15,10), date_time_init(2015,1,7,15,15,10).prev_weekday