diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-11-07 16:43:25 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-11-07 16:43:25 -0800 |
commit | cb976371e43c90a995afb1224c325c7eed4fc194 (patch) | |
tree | 539aafbaeace6c5e099ecda899a8c7ccc958077f /activesupport/test | |
parent | c2fc9848b1495768a4c550e4cc532882146902c9 (diff) | |
parent | 2e085f67d4132ac8e01dae5a4428014f51fd4829 (diff) | |
download | rails-cb976371e43c90a995afb1224c325c7eed4fc194.tar.gz rails-cb976371e43c90a995afb1224c325c7eed4fc194.tar.bz2 rails-cb976371e43c90a995afb1224c325c7eed4fc194.zip |
Merge pull request #17493 from petewest/duration-comparable
Delegate comparison operator to value
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/duration_test.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/duration_test.rb b/activesupport/test/core_ext/duration_test.rb index a5d254e115..2b893c7cd0 100644 --- a/activesupport/test/core_ext/duration_test.rb +++ b/activesupport/test/core_ext/duration_test.rb @@ -199,4 +199,16 @@ class DurationTest < ActiveSupport::TestCase def test_hash assert_equal 1.minute.hash, 60.seconds.hash end + + def test_comparable + assert_equal(-1, (0.seconds <=> 1.second)) + assert_equal(-1, (1.second <=> 1.minute)) + assert_equal(-1, (1 <=> 1.minute)) + assert_equal(0, (0.seconds <=> 0.seconds)) + assert_equal(0, (0.seconds <=> 0.minutes)) + assert_equal(0, (1.second <=> 1.second)) + assert_equal(1, (1.second <=> 0.second)) + assert_equal(1, (1.minute <=> 1.second)) + assert_equal(1, (61 <=> 1.minute)) + end end |