Ensure that short duration blockss are shown as '0 hours'

Passing `:count => nil` means that i18n.t will return the hash of translations, so use a default value of 0 when checking for hours to prevent this.

Refs #3210
This commit is contained in:
Andy Allan 2021-06-09 14:17:56 +01:00
parent baa32464cd
commit 5ce14cfa4d
2 changed files with 16 additions and 1 deletions

View file

@ -28,7 +28,7 @@ module UserBlocksHelper
def block_duration_in_words(duration)
parts = ActiveSupport::Duration.build(duration).parts
if duration < 1.day
t("user_blocks.helper.block_duration.hours", :count => parts[:hours])
t("user_blocks.helper.block_duration.hours", :count => parts.fetch(:hours, 0))
elsif duration < 1.week
t("user_blocks.helper.block_duration.days", :count => parts[:days])
elsif duration < 1.month