Remove the colon from the poll prefix, drop regex support.

This is needed to make it possible to programmatically toggle between
open and closed polls.
This commit is contained in:
Vikhyat Korrapati 2014-04-11 08:41:37 +05:30
parent edbbf7ffbb
commit 2928ce6ca1
6 changed files with 13 additions and 13 deletions

View File

@ -13,5 +13,5 @@ en:
must_contain_poll_options: "must contain a list of poll options"
cannot_have_modified_options: "cannot be modified after the first five minutes. Contact a moderator if you need to change them."
cannot_add_or_remove_options: "can only be edited, not added or removed. If you need to add or remove options you should lock this topic and create a new one."
prefix: "Poll:"
closed_prefix: "Closed Poll:"
prefix: "Poll"
closed_prefix: "Closed Poll"

View File

@ -13,5 +13,5 @@ es:
must_contain_poll_options: "debe que contener una lista con las respuestas de la encuesta"
cannot_have_modified_options: "no se pueden modificar las respuestas de la encuesta pasados 5 minutos"
cannot_add_or_remove_options: "solo se puede modificar, no se pueden añadir o quitar. Si necesitas añadir o quitar respuestas debes bloquear este tema y crear una encuesta nueva."
prefix: "Encuesta:"
closed_prefix: "Encuesta Cerrada:"
prefix: "Encuesta"
closed_prefix: "Encuesta Cerrada"

View File

@ -19,5 +19,5 @@ fr:
must_contain_poll_options: "doit contenir une liste d'options pour le sondage"
cannot_have_modified_options: "ne peuvent pas être modifiés après 5 minutes. Merci de contacter un moderateur, si vous souhaitez les modifier"
cannot_add_or_remove_options: "peuvent seulement être modifiés. Si vous souhaitez en supprimer ou en ajouter, veuillez créer un nouveau sujet."
prefix: "Sondage\\s?:"
closed_prefix: "Sondage fermé\\s?:"
prefix: "Sondage "
closed_prefix: "Sondage fermé "

View File

@ -13,5 +13,5 @@ it:
must_contain_poll_options: "deve contenere una lista di opzioni per il sondaggio"
cannot_have_modified_options: "non possono essere modificate dopo i primi cinque minuti. Contatta un moderatore se hai bisogno di cambiarle."
cannot_add_or_remove_options: "non possono essere modificate, aggiunte o rimosse. Se vuoi aggiungere o rimuovere opzioni al sondaggio, devi bloccare questo topice crearne uno nuovo."
prefix: "Sondaggio:"
closed_prefix: "Sondaggio Chiuso:"
prefix: "Sondaggio"
closed_prefix: "Sondaggio Chiuso"

View File

@ -21,7 +21,7 @@ module ::PollPlugin
return false
end
topic.title =~ /^(#{I18n.t('poll.prefix')}|#{I18n.t('poll.closed_prefix')})/i
topic.title =~ /^(#{I18n.t('poll.prefix').strip}|#{I18n.t('poll.closed_prefix').strip})\s?:/i
end
def has_poll_details?

View File

@ -14,12 +14,12 @@ describe PollPlugin::Poll do
expect(poll.is_poll?).to be_false
end
it "allows the prefix translation to contain regular expressions" do
topic.title = "Poll : This might be a poll"
it "strips whitespace from the prefix translation" do
topic.title = "Polll: This might be a poll"
topic.save
expect(PollPlugin::Poll.new(post).is_poll?).to be_false
I18n.expects(:t).with('poll.prefix').returns("Poll\\s?:")
I18n.expects(:t).with('poll.closed_prefix').returns("Closed Poll\\s?:")
I18n.expects(:t).with('poll.prefix').returns("Polll ")
I18n.expects(:t).with('poll.closed_prefix').returns("Closed Poll ")
expect(PollPlugin::Poll.new(post).is_poll?).to be_true
end