From 5996be994d7a27ffb5075d663acf02dddc32ea7e Mon Sep 17 00:00:00 2001 From: Eugen Rochko <eugen@zeonfederated.com> Date: Wed, 6 Mar 2019 04:54:11 +0100 Subject: [PATCH] Fix poll validation issues (#10186) - Fix missing interpolation argument in PollValidator - Fix PollValidator rejecting exact allowed min/max durations --- app/validators/poll_validator.rb | 4 ++-- config/locales/co.yml | 4 ++-- config/locales/cs.yml | 4 ++-- config/locales/el.yml | 4 ++-- config/locales/en.yml | 4 ++-- config/locales/fa.yml | 4 ++-- config/locales/fr.yml | 4 ++-- config/locales/gl.yml | 4 ++-- config/locales/ko.yml | 4 ++-- config/locales/sk.yml | 4 ++-- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/app/validators/poll_validator.rb b/app/validators/poll_validator.rb index d4ae4c16a..fd497c8d0 100644 --- a/app/validators/poll_validator.rb +++ b/app/validators/poll_validator.rb @@ -13,7 +13,7 @@ class PollValidator < ActiveModel::Validator poll.errors.add(:options, I18n.t('polls.errors.too_many_options', max: MAX_OPTIONS)) if poll.options.size > MAX_OPTIONS poll.errors.add(:options, I18n.t('polls.errors.over_character_limit', max: MAX_OPTION_CHARS)) if poll.options.any? { |option| option.mb_chars.grapheme_length > MAX_OPTION_CHARS } poll.errors.add(:options, I18n.t('polls.errors.duplicate_options')) unless poll.options.uniq.size == poll.options.size - poll.errors.add(:expires_at, I18n.t('polls.errors.duration_too_long')) if poll.expires_at.nil? || poll.expires_at - current_time >= MAX_EXPIRATION - poll.errors.add(:expires_at, I18n.t('polls.errors.duration_too_short')) if poll.expires_at.present? && poll.expires_at - current_time <= MIN_EXPIRATION + poll.errors.add(:expires_at, I18n.t('polls.errors.duration_too_long')) if poll.expires_at.nil? || poll.expires_at - current_time > MAX_EXPIRATION + poll.errors.add(:expires_at, I18n.t('polls.errors.duration_too_short')) if poll.expires_at.present? && poll.expires_at - current_time < MIN_EXPIRATION end end diff --git a/config/locales/co.yml b/config/locales/co.yml index d30fc9e96..8fcb27598 100644 --- a/config/locales/co.yml +++ b/config/locales/co.yml @@ -741,9 +741,9 @@ co: duration_too_long: hè troppu luntanu indè u futuru duration_too_short: hè troppu prossimu expired: U scandagliu hè digià finitu - over_character_limit: ùn ponu micca esse più longhi chè %{MAX} caratteri + over_character_limit: ùn ponu micca esse più longhi chè %{max} caratteri too_few_options: deve avè più d'un'uzzione - too_many_options: ùn pò micca avè più di %{MAX} uzzione + too_many_options: ùn pò micca avè più di %{max} uzzione preferences: languages: Lingue other: Altre diff --git a/config/locales/cs.yml b/config/locales/cs.yml index e751b5266..fe83bd57a 100644 --- a/config/locales/cs.yml +++ b/config/locales/cs.yml @@ -752,9 +752,9 @@ cs: duration_too_long: je pÅ™ÃliÅ¡ daleko v budoucnosti duration_too_short: je pÅ™ÃliÅ¡ brzy expired: Anketa již skonÄila - over_character_limit: nesmà být každá delÅ¡Ã než %{MAX} znaků + over_character_limit: nesmà být každá delÅ¡Ã než %{max} znaků too_few_options: musà mÃt vÃce než jednu položku - too_many_options: nesmà obsahovat vÃce než %{MAX} položky + too_many_options: nesmà obsahovat vÃce než %{max} položky preferences: languages: Jazyky other: Ostatnà diff --git a/config/locales/el.yml b/config/locales/el.yml index ca821c4fc..35da50af7 100644 --- a/config/locales/el.yml +++ b/config/locales/el.yml @@ -740,9 +740,9 @@ el: duration_too_long: είναι Ï€Î¿Î»Ï Î¼Î±ÎºÏιά στο μÎλλον duration_too_short: είναι Ï€Î¿Î»Ï ÏƒÏντομα expired: Η ψηφοφοÏία Îχει ήδη λήξει - over_character_limit: δε μποÏεί να υπεÏβαίνει τους %{MAX} χαÏακτήÏες Îκαστη + over_character_limit: δε μποÏεί να υπεÏβαίνει τους %{max} χαÏακτήÏες Îκαστη too_few_options: Ï€ÏÎπει να Îχει πεÏισσότεÏες από μια επιλογÎÏ‚ - too_many_options: δεν μποÏεί να Îχει πεÏισσότεÏες από %{MAX} επιλογÎÏ‚ + too_many_options: δεν μποÏεί να Îχει πεÏισσότεÏες από %{max} επιλογÎÏ‚ preferences: languages: Γλώσσες other: Άλλο diff --git a/config/locales/en.yml b/config/locales/en.yml index 2d23b1eb6..f714884f9 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -741,9 +741,9 @@ en: duration_too_long: is too far into the future duration_too_short: is too soon expired: The poll has already ended - over_character_limit: cannot be longer than %{MAX} characters each + over_character_limit: cannot be longer than %{max} characters each too_few_options: must have more than one item - too_many_options: can't contain more than %{MAX} items + too_many_options: can't contain more than %{max} items preferences: languages: Languages other: Other diff --git a/config/locales/fa.yml b/config/locales/fa.yml index 4cf8f415c..4214e793c 100644 --- a/config/locales/fa.yml +++ b/config/locales/fa.yml @@ -741,9 +741,9 @@ fa: duration_too_long: در آیندهٔ خیلی دور است duration_too_short: در آیندهٔ خیلی نزدیک است expired: این نظرسنجی به پایان رسیده است - over_character_limit: هر کدام نمی‌تواند از %{MAX} نویسه طولانی‌تر باشد + over_character_limit: هر کدام نمی‌تواند از %{max} نویسه طولانی‌تر باشد too_few_options: Øتماً باید بیش از یک گزینه داشته باشد - too_many_options: نمی‌تواند بیشتر از %{MAX} گزینه داشته باشد + too_many_options: نمی‌تواند بیشتر از %{max} گزینه داشته باشد preferences: languages: تنظیمات زبان other: سایر تنظیمات diff --git a/config/locales/fr.yml b/config/locales/fr.yml index c84dc8063..b9d813e9e 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -741,9 +741,9 @@ fr: duration_too_long: est trop loin dans le futur duration_too_short: est trop tôt expired: Ce sondage est déjà terminé - over_character_limit: ne peuvent être plus long que %{MAX} caractères chacun + over_character_limit: ne peuvent être plus long que %{max} caractères chacun too_few_options: doit avoir plus qu'une proposition - too_many_options: ne peut contenir plus que %{MAX} propositions + too_many_options: ne peut contenir plus que %{max} propositions preferences: languages: Langues other: Autre diff --git a/config/locales/gl.yml b/config/locales/gl.yml index 3c58e04f5..2435137f9 100644 --- a/config/locales/gl.yml +++ b/config/locales/gl.yml @@ -741,9 +741,9 @@ gl: duration_too_long: está moi lonxe no futuro duration_too_short: é demasiado cedo expired: A sondaxe rematou - over_character_limit: non poden ter máis de %{MAX} caracteres cada unha + over_character_limit: non poden ter máis de %{max} caracteres cada unha too_few_options: debe ter máis de unha opción - too_many_options: non pode haber máis de %{MAX} opcións + too_many_options: non pode haber máis de %{max} opcións preferences: languages: Idiomas other: Outro diff --git a/config/locales/ko.yml b/config/locales/ko.yml index 6fa18b12a..fe347a703 100644 --- a/config/locales/ko.yml +++ b/config/locales/ko.yml @@ -743,9 +743,9 @@ ko: duration_too_long: 너무 먼 미래입니다 duration_too_short: 너무 ê°€ê¹ìŠµë‹ˆë‹¤ expired: 투표가 ì´ë¯¸ ë났습니다 - over_character_limit: ê°ê° %{MAX} 글ìžë¥¼ ë„˜ì„ ìˆ˜ 없습니다 + over_character_limit: ê°ê° %{max} 글ìžë¥¼ ë„˜ì„ ìˆ˜ 없습니다 too_few_options: 한가지 ì´ìƒì˜ í•ëª©ì„ í¬í•¨í•´ì•¼ 합니다 - too_many_options: í•ëª©ì€ %{MAX}개를 ë„˜ì„ ìˆ˜ 없습니다 + too_many_options: í•ëª©ì€ %{max}개를 ë„˜ì„ ìˆ˜ 없습니다 preferences: languages: 언어 other: 기타 diff --git a/config/locales/sk.yml b/config/locales/sk.yml index b29a7a934..0800b8f8c 100644 --- a/config/locales/sk.yml +++ b/config/locales/sk.yml @@ -752,9 +752,9 @@ sk: duration_too_long: je prÃliÅ¡ Äaleko do budúcnosti duration_too_short: je prÃliÅ¡ skoro expired: Anketa už skonÄila - over_character_limit: každá nemôže byÅ¥ dlhÅ¡ia ako %{MAX} znakov + over_character_limit: každá nemôže byÅ¥ dlhÅ¡ia ako %{max} znakov too_few_options: musà maÅ¥ viac ako jednu položku - too_many_options: nemôže zahŕňaÅ¥ viac ako %{MAX} položiek + too_many_options: nemôže zahŕňaÅ¥ viac ako %{max} položiek preferences: languages: Jazyky other: Ostatné -- GitLab