aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test
diff options
context:
space:
mode:
authorAndrew White <pixeltrix@users.noreply.github.com>2017-04-27 21:11:46 +0100
committerGitHub <noreply@github.com>2017-04-27 21:11:46 +0100
commit2878f835b2615c41d6e699985bd453d3385e7f5e (patch)
tree9ff2d33c6b2302759757b872d203f148f2e5afd8 /actionview/test
parent55e3476ece18f47c0469b7e7459b1f90322d0b32 (diff)
parent756de667ae9a4b17a7ab6c7e4b17e73e67c27cba (diff)
downloadrails-2878f835b2615c41d6e699985bd453d3385e7f5e.tar.gz
rails-2878f835b2615c41d6e699985bd453d3385e7f5e.tar.bz2
rails-2878f835b2615c41d6e699985bd453d3385e7f5e.zip
Merge pull request #20701 from iamvery/date-helper-argument-error
Ensure input to distance_of_time_in_words is not nil
Diffstat (limited to 'actionview/test')
-rw-r--r--actionview/test/template/date_helper_test.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/actionview/test/template/date_helper_test.rb b/actionview/test/template/date_helper_test.rb
index d257147e1f..a259752d6a 100644
--- a/actionview/test/template/date_helper_test.rb
+++ b/actionview/test/template/date_helper_test.rb
@@ -128,6 +128,16 @@ class DateHelperTest < ActionView::TestCase
assert_distance_of_time_in_words(from)
end
+ def test_distance_in_words_with_nil_input
+ assert_raises(ArgumentError) { distance_of_time_in_words(nil) }
+ assert_raises(ArgumentError) { distance_of_time_in_words(0, nil) }
+ end
+
+ def test_distance_in_words_with_mixed_argument_types
+ assert_equal "1 minute", distance_of_time_in_words(0, Time.at(60))
+ assert_equal "10 minutes", distance_of_time_in_words(Time.at(600), 0)
+ end
+
def test_distance_in_words_with_mathn_required
# test we avoid Integer#/ (redefined by mathn)
silence_warnings { require "mathn" }