DEV: Require scheduled job in development to avoid loading file twice.

DEV: Require scheduled job in development to avoid loading file twice.

This removes the need to memoize constant in order to avoid the “warning: already initialized constant”.

diff --git a/app/jobs/scheduled/grant_new_user_of_the_month_badges.rb b/app/jobs/scheduled/grant_new_user_of_the_month_badges.rb
index 4cd1616..3359b93 100644
--- a/app/jobs/scheduled/grant_new_user_of_the_month_badges.rb
+++ b/app/jobs/scheduled/grant_new_user_of_the_month_badges.rb
@@ -4,7 +4,7 @@ module Jobs
   class GrantNewUserOfTheMonthBadges < ::Jobs::Scheduled
     every 1.day
 
-    MAX_AWARDED ||= 2
+    MAX_AWARDED = 2
 
     def execute(args)
       badge = Badge.find(Badge::NewUserOfTheMonth)
diff --git a/app/jobs/scheduled/old_keys_reminder.rb b/app/jobs/scheduled/old_keys_reminder.rb
index 98d9d11..f5318c7 100644
--- a/app/jobs/scheduled/old_keys_reminder.rb
+++ b/app/jobs/scheduled/old_keys_reminder.rb
@@ -4,7 +4,7 @@ module Jobs
   class OldKeysReminder < ::Jobs::Scheduled
     every 1.month
 
-    OLD_CREDENTIALS_PERIOD ||= 2.years
+    OLD_CREDENTIALS_PERIOD = 2.years
 
     def execute(_args)
       return if SiteSetting.send_old_credential_reminder_days.to_i == 0
diff --git a/app/jobs/scheduled/poll_mailbox.rb b/app/jobs/scheduled/poll_mailbox.rb
index 8592ed3..a016ec2 100644
--- a/app/jobs/scheduled/poll_mailbox.rb
+++ b/app/jobs/scheduled/poll_mailbox.rb
@@ -23,7 +23,7 @@ module Jobs
       Email::Processor.process!(popmail.pop)
     end
 
-    POLL_MAILBOX_TIMEOUT_ERROR_KEY ||= "poll_mailbox_timeout_error_key"
+    POLL_MAILBOX_TIMEOUT_ERROR_KEY = "poll_mailbox_timeout_error_key"
 
     def poll_pop3
       pop3 = Net::POP3.new(SiteSetting.pop3_polling_host, SiteSetting.pop3_polling_port)
@@ -62,7 +62,7 @@ module Jobs
       Discourse.handle_job_exception(e, error_context(@args, "Signing in to poll incoming emails."))
     end
 
-    POLL_MAILBOX_ERRORS_KEY ||= "poll_mailbox_errors"
+    POLL_MAILBOX_ERRORS_KEY = "poll_mailbox_errors"
 
     def self.errors_in_past_24_hours
       Discourse.redis.zremrangebyscore(POLL_MAILBOX_ERRORS_KEY, 0, 24.hours.ago.to_i)
diff --git a/app/jobs/scheduled/reindex_search.rb b/app/jobs/scheduled/reindex_search.rb
index 16da800..3d6579c 100644
--- a/app/jobs/scheduled/reindex_search.rb
+++ b/app/jobs/scheduled/reindex_search.rb
@@ -5,7 +5,7 @@ module Jobs
   class ReindexSearch < ::Jobs::Scheduled
     every 2.hours
 
-    CLEANUP_GRACE_PERIOD ||= 1.day.ago
+    CLEANUP_GRACE_PERIOD = 1.day.ago
 
     def execute(args)
       @verbose = true if args && Hash === args && args[:verbose]
diff --git a/config/initializers/100-sidekiq.rb b/config/initializers/100-sidekiq.rb
index dc488ec..56588ef 100644
--- a/config/initializers/100-sidekiq.rb
+++ b/config/initializers/100-sidekiq.rb
@@ -3,8 +3,9 @@
 # Ensure that scheduled jobs are loaded before mini_scheduler is configured.
 if Rails.env == "development" && Sidekiq.server?
   require "jobs/base"
+
   Dir.glob("#{Rails.root}/app/jobs/scheduled/*.rb") do |f|
-    load(f)
+    require(f)
   end
 end
 

GitHub sha: 069a109c