Correct flaky spec

Correct flaky spec

diff --git a/spec/models/topic_timer_spec.rb b/spec/models/topic_timer_spec.rb
index b702f9a..cd6f2e2 100644
--- a/spec/models/topic_timer_spec.rb
+++ b/spec/models/topic_timer_spec.rb
@@ -273,13 +273,17 @@ RSpec.describe TopicTimer, type: :model do
         topic: Fabricate(:topic, closed: true)
       )
 
-      Fabricate(:topic_timer)
+      Fabricate(:topic_timer, execute_at: Time.zone.now + 1.hour)
 
       Fabricate(:topic_timer,
         execute_at: Time.zone.now - 1.hour,
         created_at: Time.zone.now - 2.hour
       ).topic.trash!
 
+      # creating topic timers already enqueues jobs
+      # let's delete them to test ensure_consistency!
+      Sidekiq::Worker.clear_all
+
       expect { described_class.ensure_consistency! }
         .to change { Jobs::ToggleTopicClosed.jobs.count }.by(2)
 
@@ -294,19 +298,22 @@ RSpec.describe TopicTimer, type: :model do
       expect(job_args["state"]).to eq(false)
     end
 
-    # intermittent failures
-    # it "should enqueue remind me jobs that have been missed" do
-    #   reminder = Fabricate(:topic_timer,
-    #     status_type: described_class.types[:reminder],
-    #     execute_at: Time.zone.now - 1.hour,
-    #     created_at: Time.zone.now - 2.hour
-    #   )
+    it "should enqueue remind me jobs that have been missed" do
+      reminder = Fabricate(:topic_timer,
+        status_type: described_class.types[:reminder],
+        execute_at: Time.zone.now - 1.hour,
+        created_at: Time.zone.now - 2.hour
+      )
 
-    #   expect { described_class.ensure_consistency! }
-    #     .to change { Jobs::TopicReminder.jobs.count }.by(1)
+      # creating topic timers already enqueues jobs
+      # let's delete them to test ensure_consistency!
+      Sidekiq::Worker.clear_all
 
-    #   job_args = Jobs::TopicReminder.jobs.first["args"].first
-    #   expect(job_args["topic_timer_id"]).to eq(reminder.id)
-    # end
+      expect { described_class.ensure_consistency! }
+        .to change { Jobs::TopicReminder.jobs.count }.by(1)
+
+      job_args = Jobs::TopicReminder.jobs.first["args"].first
+      expect(job_args["topic_timer_id"]).to eq(reminder.id)
+    end
   end
 end

GitHub sha: 216f4c99