diff options
author | Shigeya Suzuki <shigeya@wide.ad.jp> | 2012-02-09 22:08:28 -0800 |
---|---|---|
committer | Shigeya Suzuki <shigeya@wide.ad.jp> | 2012-02-09 22:08:28 -0800 |
commit | 6f68e632746f72469cbd1c1b6cb9d3f1ed1730a0 (patch) | |
tree | fbef94df48e7bab274826ad24fa9f278b8c5db99 /activesupport/test | |
parent | 75ffd8701d04d943eddcafee08e19b90bce8936c (diff) | |
download | rails-6f68e632746f72469cbd1c1b6cb9d3f1ed1730a0.tar.gz rails-6f68e632746f72469cbd1c1b6cb9d3f1ed1730a0.tar.bz2 rails-6f68e632746f72469cbd1c1b6cb9d3f1ed1730a0.zip |
make Range#overlaps? accept Range of Time
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/range_ext_test.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/range_ext_test.rb b/activesupport/test/core_ext/range_ext_test.rb index 8a91f6d69c..cf1ec448c2 100644 --- a/activesupport/test/core_ext/range_ext_test.rb +++ b/activesupport/test/core_ext/range_ext_test.rb @@ -71,4 +71,16 @@ class RangeTest < ActiveSupport::TestCase range = (1..3) assert range.method(:include?) != range.method(:cover?) end + + def test_overlaps_on_time + time_range_1 = Time.utc(2005, 12, 10, 15, 30)..Time.utc(2005, 12, 10, 17, 30) + time_range_2 = Time.utc(2005, 12, 10, 17, 00)..Time.utc(2005, 12, 10, 18, 00) + assert time_range_1.overlaps?(time_range_2) + end + + def test_no_overlaps_on_time + time_range_1 = Time.utc(2005, 12, 10, 15, 30)..Time.utc(2005, 12, 10, 17, 30) + time_range_2 = Time.utc(2005, 12, 10, 17, 31)..Time.utc(2005, 12, 10, 18, 00) + assert !time_range_1.overlaps?(time_range_2) + end end |