FIX: migrate_old_polls should properly identify olds polls at the end of the post
This commit is contained in:
parent
4da6124fa5
commit
0ded6434df
|
@ -14,13 +14,12 @@ task "poll:migrate_old_polls" => :environment do
|
||||||
# go back in time
|
# go back in time
|
||||||
Timecop.freeze(post.created_at + 1.minute) do
|
Timecop.freeze(post.created_at + 1.minute) do
|
||||||
# fix the RAW when needed
|
# fix the RAW when needed
|
||||||
|
post.raw << "\n\n"
|
||||||
if post.raw !~ /\[poll\]/
|
if post.raw !~ /\[poll\]/
|
||||||
lists = /^[ ]*- .+?$\n\n/m.match(post.raw)
|
lists = /^[ ]*- .+?$\n\n/m.match(post.raw)
|
||||||
next if lists.blank? || lists.length == 0
|
next if lists.blank? || lists.length == 0
|
||||||
first_list = lists[0]
|
first_list = lists[0]
|
||||||
post.raw = post.raw.sub(first_list, "\n[poll]\n#{first_list.strip}\n[/poll]\n")
|
post.raw = post.raw.sub(first_list, "\n[poll]\n#{first_list.strip}\n[/poll]\n")
|
||||||
else
|
|
||||||
post.raw = post.raw + " "
|
|
||||||
end
|
end
|
||||||
# save the poll
|
# save the poll
|
||||||
post.save
|
post.save
|
||||||
|
|
Loading…
Reference in New Issue