Fix case when user block durations are slightly negative

The output from ActiveSupport::Duration is wildly unhelpful in those cases

Fixes #3210
This commit is contained in:
Andy Allan 2021-06-09 15:14:14 +01:00
parent 5ce14cfa4d
commit 71be435886
2 changed files with 7 additions and 0 deletions

View file

@ -27,5 +27,10 @@ class UserBlocksHelperTest < ActionView::TestCase
words = block_duration_in_words(0)
assert_equal "0 hours", words
# Ensure that (slightly) negative durations don't mess everything up
# This can happen on zero hour blocks when ends_at is a millisecond before created_at
words = block_duration_in_words(-0.001)
assert_equal "0 hours", words
end
end