mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 15:32:26 +08:00
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
|
||||
Timecop.freeze(post.created_at + 1.minute) do
|
||||
# fix the RAW when needed
|
||||
post.raw << "\n\n"
|
||||
if post.raw !~ /\[poll\]/
|
||||
lists = /^[ ]*- .+?$\n\n/m.match(post.raw)
|
||||
next if lists.blank? || lists.length == 0
|
||||
first_list = lists[0]
|
||||
post.raw = post.raw.sub(first_list, "\n[poll]\n#{first_list.strip}\n[/poll]\n")
|
||||
else
|
||||
post.raw = post.raw + " "
|
||||
end
|
||||
# save the poll
|
||||
post.save
|
||||
|
|
Loading…
Reference in New Issue
Block a user