From f916087e81ff70119c10745acea94917d7cae9e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Wed, 18 Feb 2015 20:33:05 +0100 Subject: [PATCH] FIX: poll plugin wasn't working when the OP was deleted Alternatively fixes issue reported -> https://meta.discourse.org/t/bug-with-flag-as-spam/25359 --- plugins/poll/poll.rb | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/plugins/poll/poll.rb b/plugins/poll/poll.rb index 9d663951fca..35ceab7c37d 100644 --- a/plugins/poll/poll.rb +++ b/plugins/poll/poll.rb @@ -6,20 +6,16 @@ module ::PollPlugin end def is_poll? - if !@post.post_number.nil? and @post.post_number > 1 - # Not a new post, and also not the first post. - return false - end + # Not a new post, and also not the first post. + return false if @post.post_number.present? && @post.post_number > 1 topic = @post.topic # Topic is not set in a couple of cases in the Discourse test suite. - return false if topic.nil? + return false if topic.nil? || topic.user.nil? - if @post.post_number.nil? and topic.highest_post_number > 0 - # New post, but not the first post in the topic. - return false - end + # New post, but not the first post in the topic. + return false if @post.post_number.nil? && topic.highest_post_number > 0 I18n.with_locale(topic.user.effective_locale) do topic.title =~ /^(#{I18n.t('poll.prefix').strip}|#{I18n.t('poll.closed_prefix').strip})\s?:/i