diff options
author | Robin Dupret <robin.dupret@gmail.com> | 2014-08-23 13:09:41 +0200 |
---|---|---|
committer | Robin Dupret <robin.dupret@gmail.com> | 2014-08-24 18:17:46 +0200 |
commit | d5578cd17716fbda11ec37ce7489699d191878a3 (patch) | |
tree | 99b3b4d9e23c3a10500d9f9f352c568e3993adbd /activesupport/test | |
parent | 4287f6d456518652bb1a2035c9ecf96f1be28f79 (diff) | |
download | rails-d5578cd17716fbda11ec37ce7489699d191878a3.tar.gz rails-d5578cd17716fbda11ec37ce7489699d191878a3.tar.bz2 rails-d5578cd17716fbda11ec37ce7489699d191878a3.zip |
Follow-up to #16560
For the sake of backward-compatibility, we need to make #instance_of?
return true for Fixnum. On the other hand, the method should still
give true for ActiveSupport::Duration itself which was not the case
before.
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/duration_test.rb | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/activesupport/test/core_ext/duration_test.rb b/activesupport/test/core_ext/duration_test.rb index 330d995b7c..8d7be4857b 100644 --- a/activesupport/test/core_ext/duration_test.rb +++ b/activesupport/test/core_ext/duration_test.rb @@ -20,6 +20,12 @@ class DurationTest < ActiveSupport::TestCase assert !d.is_a?(k) end + def test_instance_of + assert 1.minute.instance_of?(Fixnum) + assert 2.days.instance_of?(ActiveSupport::Duration) + assert !3.second.instance_of?(Numeric) + end + def test_threequals assert ActiveSupport::Duration === 1.day assert !(ActiveSupport::Duration === 1.day.to_i) @@ -41,11 +47,6 @@ class DurationTest < ActiveSupport::TestCase assert !1.eql?(1.second) end - def test_instance_of - assert !1.minute.instance_of?(Fixnum) - assert !2.days.instance_of?(Fixnum) - end - def test_inspect assert_equal '0 seconds', 0.seconds.inspect assert_equal '1 month', 1.month.inspect |