2019-04-29 20:27:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-07-27 22:27:38 -04:00
|
|
|
RSpec.describe Jobs::PeriodicalUpdates do
|
2014-02-26 20:15:41 -05:00
|
|
|
it "works" do
|
|
|
|
# does not blow up, no mocks, everything is called
|
|
|
|
Jobs::PeriodicalUpdates.new.execute(nil)
|
2013-03-28 13:02:59 -04:00
|
|
|
end
|
|
|
|
|
2018-12-09 11:36:04 -05: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-08 16:57:20 -05: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-16 22:53:09 -05:00
|
|
|
expect(jobs[0]["queue"]).to eq("ultra_low")
|
2019-01-08 16:57:20 -05:00
|
|
|
end
|
2018-12-09 11:36:04 -05:00
|
|
|
|
|
|
|
post.reload
|
|
|
|
expect(post.baked_at).to be > 1.day.ago
|
|
|
|
baked = post.baked_at
|
2019-01-08 16:57:20 -05:00
|
|
|
|
|
|
|
# does not rebake
|
|
|
|
Jobs::PeriodicalUpdates.new.execute
|
2018-12-09 11:36:04 -05:00
|
|
|
post.reload
|
2020-03-10 17:13:17 -04:00
|
|
|
expect(post.baked_at).to eq_time(baked)
|
2018-12-09 11:36:04 -05:00
|
|
|
end
|
2013-03-28 13:02:59 -04:00
|
|
|
end
|