Add test to check if posts are auto rebaked by PeriodicalUpdates job when gravatar download is disabled follow-up for 8e307e633eb7e3ef2b928fa45aff5245c40c870e

Add test to check if posts are auto rebaked by PeriodicalUpdates job when gravatar download is disabled follow-up for 8e307e633eb7e3ef2b928fa45aff5245c40c870e
From da41a515cd30a45a38d708b4c741bc99a977c275 Mon Sep 17 00:00:00 2001
From: Rishabh <rishabh.nambiar@discourse.org>
Date: Sun, 9 Dec 2018 22:06:04 +0530
Subject: [PATCH] Add test to check if posts are auto rebaked by
 PeriodicalUpdates job when gravatar download is disabled follow-up for
 8e307e633eb7e3ef2b928fa45aff5245c40c870e


diff --git a/spec/jobs/periodical_updates_spec.rb b/spec/jobs/periodical_updates_spec.rb
index 7c4e79c..b2ba6c6 100644
--- a/spec/jobs/periodical_updates_spec.rb
+++ b/spec/jobs/periodical_updates_spec.rb
@@ -9,4 +9,18 @@ describe Jobs::PeriodicalUpdates do
     Jobs::PeriodicalUpdates.new.execute(nil)
   end
 
+  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)
+    described_class.new.execute({})
+
+    post.reload
+    expect(post.baked_at).to be > 1.day.ago
+
+    baked = post.baked_at
+    described_class.new.execute({})
+    post.reload
+    expect(post.baked_at).to eq(baked)
+  end
 end

GitHub

1 Like