diff options
author | Ionatan Wiznia <ionatan.wiznia@traddia.com> | 2013-10-11 12:50:23 +0200 |
---|---|---|
committer | Ionatan Wiznia <ionatan.wiznia@traddia.com> | 2013-10-11 12:50:23 +0200 |
commit | 90871f7198f0739c82df2f1bbb66c5f8dd5a720a (patch) | |
tree | 334ed4365a5948da0aaacbdd692338f280c17244 /activesupport/test | |
parent | 0061c5e1ef0f7be8946602456a538c263fcafed2 (diff) | |
download | rails-90871f7198f0739c82df2f1bbb66c5f8dd5a720a.tar.gz rails-90871f7198f0739c82df2f1bbb66c5f8dd5a720a.tar.bz2 rails-90871f7198f0739c82df2f1bbb66c5f8dd5a720a.zip |
flatten and flatten! methods for ActiveSupport::Duration
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/duration_test.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/duration_test.rb b/activesupport/test/core_ext/duration_test.rb index ed267cf4b9..cc24d7c74c 100644 --- a/activesupport/test/core_ext/duration_test.rb +++ b/activesupport/test/core_ext/duration_test.rb @@ -145,6 +145,21 @@ class DurationTest < ActiveSupport::TestCase assert_equal '172800', 2.days.to_json end + def test_flatten + a = 2.months + b = (1.month + 1.month).flatten + + assert_equal a.parts, b.parts + end + + def test_flatten! + a = (1.month + 1.month) + b = a.flatten + a.flatten! + + assert_equal a.parts, b.parts + end + protected def with_env_tz(new_tz = 'US/Eastern') old_tz, ENV['TZ'] = ENV['TZ'], new_tz |