Skip to content

Commit 322279b

Browse files
Gargronhiyuki2578
authored andcommitted
Fix poll validation issues (mastodon#10186)
- Fix missing interpolation argument in PollValidator - Fix PollValidator rejecting exact allowed min/max durations
1 parent 30a76c3 commit 322279b

10 files changed

Lines changed: 20 additions & 20 deletions

File tree

app/validators/poll_validator.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def validate(poll)
1313
poll.errors.add(:options, I18n.t('polls.errors.too_many_options', max: MAX_OPTIONS)) if poll.options.size > MAX_OPTIONS
1414
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 }
1515
poll.errors.add(:options, I18n.t('polls.errors.duplicate_options')) unless poll.options.uniq.size == poll.options.size
16-
poll.errors.add(:expires_at, I18n.t('polls.errors.duration_too_long')) if poll.expires_at.nil? || poll.expires_at - current_time >= MAX_EXPIRATION
17-
poll.errors.add(:expires_at, I18n.t('polls.errors.duration_too_short')) if poll.expires_at.present? && poll.expires_at - current_time <= MIN_EXPIRATION
16+
poll.errors.add(:expires_at, I18n.t('polls.errors.duration_too_long')) if poll.expires_at.nil? || poll.expires_at - current_time > MAX_EXPIRATION
17+
poll.errors.add(:expires_at, I18n.t('polls.errors.duration_too_short')) if poll.expires_at.present? && poll.expires_at - current_time < MIN_EXPIRATION
1818
end
1919
end

config/locales/co.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,9 +741,9 @@ co:
741741
duration_too_long: hè troppu luntanu indè u futuru
742742
duration_too_short: hè troppu prossimu
743743
expired: U scandagliu hè digià finitu
744-
over_character_limit: ùn ponu micca esse più longhi chè %{MAX} caratteri
744+
over_character_limit: ùn ponu micca esse più longhi chè %{max} caratteri
745745
too_few_options: deve avè più d'un'uzzione
746-
too_many_options: ùn pò micca avè più di %{MAX} uzzione
746+
too_many_options: ùn pò micca avè più di %{max} uzzione
747747
preferences:
748748
languages: Lingue
749749
other: Altre

config/locales/cs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -752,9 +752,9 @@ cs:
752752
duration_too_long: je příliš daleko v budoucnosti
753753
duration_too_short: je příliš brzy
754754
expired: Anketa již skončila
755-
over_character_limit: nesmí být každá delší než %{MAX} znaků
755+
over_character_limit: nesmí být každá delší než %{max} znaků
756756
too_few_options: musí mít více než jednu položku
757-
too_many_options: nesmí obsahovat více než %{MAX} položky
757+
too_many_options: nesmí obsahovat více než %{max} položky
758758
preferences:
759759
languages: Jazyky
760760
other: Ostatní

config/locales/el.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -740,9 +740,9 @@ el:
740740
duration_too_long: είναι πολύ μακριά στο μέλλον
741741
duration_too_short: είναι πολύ σύντομα
742742
expired: Η ψηφοφορία έχει ήδη λήξει
743-
over_character_limit: δε μπορεί να υπερβαίνει τους %{MAX} χαρακτήρες έκαστη
743+
over_character_limit: δε μπορεί να υπερβαίνει τους %{max} χαρακτήρες έκαστη
744744
too_few_options: πρέπει να έχει περισσότερες από μια επιλογές
745-
too_many_options: δεν μπορεί να έχει περισσότερες από %{MAX} επιλογές
745+
too_many_options: δεν μπορεί να έχει περισσότερες από %{max} επιλογές
746746
preferences:
747747
languages: Γλώσσες
748748
other: Άλλο

config/locales/en.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,9 +741,9 @@ en:
741741
duration_too_long: is too far into the future
742742
duration_too_short: is too soon
743743
expired: The poll has already ended
744-
over_character_limit: cannot be longer than %{MAX} characters each
744+
over_character_limit: cannot be longer than %{max} characters each
745745
too_few_options: must have more than one item
746-
too_many_options: can't contain more than %{MAX} items
746+
too_many_options: can't contain more than %{max} items
747747
preferences:
748748
languages: Languages
749749
other: Other

config/locales/fa.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,9 +741,9 @@ fa:
741741
duration_too_long: در آیندهٔ خیلی دور است
742742
duration_too_short: در آیندهٔ خیلی نزدیک است
743743
expired: این نظرسنجی به پایان رسیده است
744-
over_character_limit: هر کدام نمی‌تواند از %{MAX} نویسه طولانی‌تر باشد
744+
over_character_limit: هر کدام نمی‌تواند از %{max} نویسه طولانی‌تر باشد
745745
too_few_options: حتماً باید بیش از یک گزینه داشته باشد
746-
too_many_options: نمی‌تواند بیشتر از %{MAX} گزینه داشته باشد
746+
too_many_options: نمی‌تواند بیشتر از %{max} گزینه داشته باشد
747747
preferences:
748748
languages: تنظیمات زبان
749749
other: سایر تنظیمات

config/locales/fr.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,9 +741,9 @@ fr:
741741
duration_too_long: est trop loin dans le futur
742742
duration_too_short: est trop tôt
743743
expired: Ce sondage est déjà terminé
744-
over_character_limit: ne peuvent être plus long que %{MAX} caractères chacun
744+
over_character_limit: ne peuvent être plus long que %{max} caractères chacun
745745
too_few_options: doit avoir plus qu'une proposition
746-
too_many_options: ne peut contenir plus que %{MAX} propositions
746+
too_many_options: ne peut contenir plus que %{max} propositions
747747
preferences:
748748
languages: Langues
749749
other: Autre

config/locales/gl.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,9 +741,9 @@ gl:
741741
duration_too_long: está moi lonxe no futuro
742742
duration_too_short: é demasiado cedo
743743
expired: A sondaxe rematou
744-
over_character_limit: non poden ter máis de %{MAX} caracteres cada unha
744+
over_character_limit: non poden ter máis de %{max} caracteres cada unha
745745
too_few_options: debe ter máis de unha opción
746-
too_many_options: non pode haber máis de %{MAX} opcións
746+
too_many_options: non pode haber máis de %{max} opcións
747747
preferences:
748748
languages: Idiomas
749749
other: Outro

config/locales/ko.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -743,9 +743,9 @@ ko:
743743
duration_too_long: 너무 먼 미래입니다
744744
duration_too_short: 너무 가깝습니다
745745
expired: 투표가 이미 끝났습니다
746-
over_character_limit: 각각 %{MAX} 글자를 넘을 수 없습니다
746+
over_character_limit: 각각 %{max} 글자를 넘을 수 없습니다
747747
too_few_options: 한가지 이상의 항목을 포함해야 합니다
748-
too_many_options: 항목은 %{MAX}개를 넘을 수 없습니다
748+
too_many_options: 항목은 %{max}개를 넘을 수 없습니다
749749
preferences:
750750
languages: 언어
751751
other: 기타

config/locales/sk.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -752,9 +752,9 @@ sk:
752752
duration_too_long: je príliš ďaleko do budúcnosti
753753
duration_too_short: je príliš skoro
754754
expired: Anketa už skončila
755-
over_character_limit: každá nemôže byť dlhšia ako %{MAX} znakov
755+
over_character_limit: každá nemôže byť dlhšia ako %{max} znakov
756756
too_few_options: musí mať viac ako jednu položku
757-
too_many_options: nemôže zahŕňať viac ako %{MAX} položiek
757+
too_many_options: nemôže zahŕňať viac ako %{max} položiek
758758
preferences:
759759
languages: Jazyky
760760
other: Ostatné

0 commit comments

Comments
 (0)