From d889f05480f6f96b01ba08069bafd402c9a4a28c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= <regis@hanol.fr> Date: Tue, 19 May 2015 14:33:27 +0200 Subject: [PATCH] changed default 'poll maximum options' to 20 --- plugins/poll/config/settings.yml | 2 +- plugins/poll/lib/tasks/migrate_old_polls.rake | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/poll/config/settings.yml b/plugins/poll/config/settings.yml index 354288bf720..bdeb59954c9 100644 --- a/plugins/poll/config/settings.yml +++ b/plugins/poll/config/settings.yml @@ -2,4 +2,4 @@ plugins: poll_enabled: default: true poll_maximum_options: - default: 10 + default: 20 diff --git a/plugins/poll/lib/tasks/migrate_old_polls.rake b/plugins/poll/lib/tasks/migrate_old_polls.rake index ea86d9bacf6..9a551a18a65 100644 --- a/plugins/poll/lib/tasks/migrate_old_polls.rake +++ b/plugins/poll/lib/tasks/migrate_old_polls.rake @@ -40,15 +40,16 @@ task "poll:migrate_old_polls" => :environment do next if post.custom_fields.include?("polls") # go back in time Timecop.freeze(post.created_at + 1.minute) do - post.raw = post.raw.gsub(/\n\n([ ]*[-\*\+] )/, "\n\\1") + "\n\n" + raw = post.raw.gsub(/\n\n([ ]*[-\*\+] )/, "\n\\1") + "\n\n" # fix the RAW when needed - if post.raw !~ /\[poll\]/ - lists = /^[ ]*[-\*\+] .+?$\n\n/m.match(post.raw) + if raw !~ /\[poll\]/ + lists = /^[ ]*[-\*\+] .+?$\n\n/m.match(raw) next if lists.blank? || lists.length == 0 first_list = lists[0] - post.raw = post.raw.sub(first_list, "\n[poll]\n#{first_list}\n[/poll]\n") + raw = raw.sub(first_list, "\n[poll]\n#{first_list}\n[/poll]\n") end # save the poll + post.raw = raw post.save # make sure we have a poll next if post.custom_fields.blank? || !post.custom_fields.include?("polls")