2019-04-30 08:27:42 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-10-11 17:41:23 +08:00
|
|
|
require 'rails_helper'
|
2013-03-29 01:02:59 +08:00
|
|
|
|
|
|
|
describe Jobs::PeriodicalUpdates do
|
|
|
|
|
2014-02-27 09:15:41 +08:00
|
|
|
it "works" do
|
2013-03-29 01:02:59 +08:00
|
|
|
|
2014-02-27 09:15:41 +08:00
|
|
|
# does not blow up, no mocks, everything is called
|
|
|
|
Jobs::PeriodicalUpdates.new.execute(nil)
|
2013-03-29 01:02:59 +08:00
|
|
|
end
|
|
|
|
|
2018-12-10 00:36:04 +08:00
|
|
|
it "can rebake old posts when automatically_download_gravatars is false" do
|
|
|
|
SiteSetting.automatically_download_gravatars = false
|
|
|
|
post = create_post
|
|
|
|
post.update_columns(baked_at: Time.new(2000, 1, 1), baked_version: -1)
|
2019-01-09 05:57:20 +08:00
|
|
|
|
|
|
|
Sidekiq::Testing.fake! do
|
|
|
|
Jobs::ProcessPost.jobs.clear
|
|
|
|
|
|
|
|
Jobs::PeriodicalUpdates.new.execute
|
|
|
|
|
|
|
|
jobs = Jobs::ProcessPost.jobs
|
|
|
|
expect(jobs.length).to eq(1)
|
|
|
|
|
2019-01-17 11:53:09 +08:00
|
|
|
expect(jobs[0]["queue"]).to eq("ultra_low")
|
2019-01-09 05:57:20 +08:00
|
|
|
end
|
2018-12-10 00:36:04 +08:00
|
|
|
|
|
|
|
post.reload
|
|
|
|
expect(post.baked_at).to be > 1.day.ago
|
|
|
|
baked = post.baked_at
|
2019-01-09 05:57:20 +08:00
|
|
|
|
|
|
|
# does not rebake
|
|
|
|
Jobs::PeriodicalUpdates.new.execute
|
2018-12-10 00:36:04 +08:00
|
|
|
post.reload
|
|
|
|
expect(post.baked_at).to eq(baked)
|
|
|
|
end
|
2013-03-29 01:02:59 +08:00
|
|
|
end
|