diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-06-28 02:36:40 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-28 02:36:40 +0900 |
commit | 5a1ea09062eaed78e21253a128d433a1beb745ad (patch) | |
tree | 389371b9a9794311c7b8e1b0c4a2e650c3e990d9 | |
parent | cb0fdaacb277bd0595bfd73178329922aa24477e (diff) | |
parent | 376b687cb70d7cd8d84bd5f7c2acc45153359985 (diff) | |
download | rails-5a1ea09062eaed78e21253a128d433a1beb745ad.tar.gz rails-5a1ea09062eaed78e21253a128d433a1beb745ad.tar.bz2 rails-5a1ea09062eaed78e21253a128d433a1beb745ad.zip |
Merge pull request #33217 from eugeneius/test_duration_preserve_parts
Add tests for duration multiplication and division
-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 240ae3bde0..63934e2433 100644 --- a/activesupport/test/core_ext/duration_test.rb +++ b/activesupport/test/core_ext/duration_test.rb @@ -158,6 +158,18 @@ class DurationTest < ActiveSupport::TestCase assert_equal Date.civil(2017, 1, 3), Date.civil(2017, 1, 1) + 1.day * 2 end + def test_date_added_with_multiplied_duration_larger_than_one_month + assert_equal Date.civil(2017, 2, 15), Date.civil(2017, 1, 1) + 1.day * 45 + end + + def test_date_added_with_divided_duration + assert_equal Date.civil(2017, 1, 3), Date.civil(2017, 1, 1) + 4.days / 2 + end + + def test_date_added_with_divided_duration_larger_than_one_month + assert_equal Date.civil(2017, 2, 15), Date.civil(2017, 1, 1) + 90.days / 2 + end + def test_plus_with_time assert_equal 1 + 1.second, 1.second + 1, "Duration + Numeric should == Numeric + Duration" end |