Add specs for RateLimiter::LimitExceeded#description.

This commit is contained in:
Guo Xiang Tan
2018-06-19 07:48:03 +08:00
parent 3725fd8345
commit 630b4570ef
2 changed files with 30 additions and 10 deletions

View File

@ -10,16 +10,16 @@ class RateLimiter
end
def description
time_left = ""
if @available_in <= 3
time_left = I18n.t("rate_limiter.short_time")
elsif @available_in < 1.minute.to_i
time_left = I18n.t("rate_limiter.seconds", count: @available_in)
elsif @available_in < 1.hour.to_i
time_left = I18n.t("rate_limiter.minutes", count: (@available_in / 1.minute.to_i))
else
time_left = I18n.t("rate_limiter.hours", count: (@available_in / 1.hour.to_i))
end
time_left =
if @available_in <= 3
I18n.t("rate_limiter.short_time")
elsif @available_in < 1.minute.to_i
I18n.t("rate_limiter.seconds", count: @available_in)
elsif @available_in < 1.hour.to_i
I18n.t("rate_limiter.minutes", count: (@available_in / 1.minute.to_i))
else
I18n.t("rate_limiter.hours", count: (@available_in / 1.hour.to_i))
end
if @type.present?
type_key = @type.tr("-", "_")