mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 16:31:09 +08:00
FEATURE: remove the timecop gem
We should only have one way of mocking time, misuse of timecop was causing build stability issues
This commit is contained in:
@ -25,7 +25,6 @@ end
|
||||
|
||||
desc "Migrate old polls to new syntax"
|
||||
task "poll:migrate_old_polls" => :environment do
|
||||
require "timecop"
|
||||
# iterate over all polls
|
||||
PluginStoreRow.where(plugin_name: "poll")
|
||||
.where("key LIKE 'poll_options_%'")
|
||||
@ -39,7 +38,7 @@ task "poll:migrate_old_polls" => :environment do
|
||||
# skip if already migrated
|
||||
next if post.custom_fields.include?("polls")
|
||||
# go back in time
|
||||
Timecop.freeze(post.created_at + 1.minute) do
|
||||
freeze_time(post.created_at + 1.minute) do
|
||||
raw = post.raw.gsub(/\n\n([ ]*[-\*\+] )/, "\n\\1") + "\n\n"
|
||||
# fix the RAW when needed
|
||||
if raw !~ /\[poll\]/
|
||||
|
@ -92,7 +92,7 @@ describe PostsController do
|
||||
describe "within the first 5 minutes" do
|
||||
|
||||
let(:post_id) do
|
||||
Timecop.freeze(4.minutes.ago) do
|
||||
freeze_time(4.minutes.ago) do
|
||||
xhr :post, :create, { title: title, raw: "[poll]\n- A\n- B\n[/poll]" }
|
||||
::JSON.parse(response.body)["id"]
|
||||
end
|
||||
@ -122,7 +122,7 @@ describe PostsController do
|
||||
let(:updated) { "before\n\n[poll]\n- A\n- B\n[/poll]\n\nafter" }
|
||||
|
||||
let(:post_id) do
|
||||
Timecop.freeze(6.minutes.ago) do
|
||||
freeze_time(6.minutes.ago) do
|
||||
xhr :post, :create, { title: title, raw: poll }
|
||||
::JSON.parse(response.body)["id"]
|
||||
end
|
||||
|
Reference in New Issue
Block a user