aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test
diff options
context:
space:
mode:
authorJay Hayes <ur@iamvery.com>2015-06-25 17:54:32 -0500
committerJay Hayes <ur@iamvery.com>2017-04-27 12:00:13 -0700
commit756de667ae9a4b17a7ab6c7e4b17e73e67c27cba (patch)
tree531c379cf08149f84c4e338fbe116ddb9fe4c0f6 /actionview/test
parentb32d64df5e5160e25804c7019e2da76bd115f3a6 (diff)
downloadrails-756de667ae9a4b17a7ab6c7e4b17e73e67c27cba.tar.gz
rails-756de667ae9a4b17a7ab6c7e4b17e73e67c27cba.tar.bz2
rails-756de667ae9a4b17a7ab6c7e4b17e73e67c27cba.zip
Ensure input to distance_of_time_in_words is not nil
* Internally all input is converted to time so that it can be treated uniformly. Remove now-unneeded condition * Now that all input is treated is converted to time, we no longer need to type check it. Rename variables to clarify their purpose Extract private method to normalize distance_of_time args to time Update actionview changelog
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" }