diff options
author | Andrew White <pixeltrix@users.noreply.github.com> | 2016-04-29 08:36:43 +0100 |
---|---|---|
committer | Andrew White <pixeltrix@users.noreply.github.com> | 2016-04-29 08:36:43 +0100 |
commit | f0a6cce78eacec932111f726cec95bb1f42a4644 (patch) | |
tree | d89bf10941906379dc93944bd37fed881cc6faa9 /activesupport/test | |
parent | 97988829ebe1662aa5bf5a4b82c312203a8b54d8 (diff) | |
parent | 434df0016e228a7d51f1ad0c3d1f89faeffbed9a (diff) | |
download | rails-f0a6cce78eacec932111f726cec95bb1f42a4644.tar.gz rails-f0a6cce78eacec932111f726cec95bb1f42a4644.tar.bz2 rails-f0a6cce78eacec932111f726cec95bb1f42a4644.zip |
Merge pull request #24762 from Envek/solid_durations_2
[FIX] Change 1.week to create 1 week durations instead of 7 days durations.
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/duration_test.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/activesupport/test/core_ext/duration_test.rb b/activesupport/test/core_ext/duration_test.rb index 69c2c0d936..ce69364c68 100644 --- a/activesupport/test/core_ext/duration_test.rb +++ b/activesupport/test/core_ext/duration_test.rb @@ -66,8 +66,9 @@ class DurationTest < ActiveSupport::TestCase assert_equal '10 years, 2 months, and 1 day', (10.years + 2.months + 1.day).inspect assert_equal '10 years, 2 months, and 1 day', (10.years + 1.month + 1.day + 1.month).inspect assert_equal '10 years, 2 months, and 1 day', (1.day + 10.years + 2.months).inspect - assert_equal '7 days', 1.week.inspect - assert_equal '14 days', 1.fortnight.inspect + assert_equal '7 days', 7.days.inspect + assert_equal '1 week', 1.week.inspect + assert_equal '2 weeks', 1.fortnight.inspect end def test_inspect_locale @@ -87,6 +88,15 @@ class DurationTest < ActiveSupport::TestCase assert_equal 1 + 1.second, 1.second + 1, "Duration + Numeric should == Numeric + Duration" end + def test_time_plus_duration_returns_same_time_datatype + twz = ActiveSupport::TimeWithZone.new(nil, ActiveSupport::TimeZone['Moscow'] , Time.utc(2016,4,28,00,45)) + now = Time.now.utc + %w( second minute hour day week month year ).each do |unit| + assert_equal((now + 1.send(unit)).class, Time, "Time + 1.#{unit} must be Time") + assert_equal((twz + 1.send(unit)).class, ActiveSupport::TimeWithZone, "TimeWithZone + 1.#{unit} must be TimeWithZone") + end + end + def test_argument_error e = assert_raise ArgumentError do 1.second.ago('') |