FIX: Zeitwerk-related fixes for jobs. (#8187)

FIX: Zeitwerk-related fixes for jobs. (#8187)

diff --git a/app/jobs/base.rb b/app/jobs/base.rb
index 9ad78f4564..b43bcb5729 100644
--- a/app/jobs/base.rb
+++ b/app/jobs/base.rb
@@ -282,7 +282,7 @@ module Jobs
   end
 
   def self.enqueue(job_name, opts = {})
-    klass = "Jobs::#{job_name.to_s.camelcase}".constantize
+    klass = "::Jobs::#{job_name.to_s.camelcase}".constantize
 
     # Unless we want to work on all sites
     unless opts.delete(:all_sites)
diff --git a/app/jobs/onceoff/retro_grant_anniversary.rb b/app/jobs/onceoff/retro_grant_anniversary.rb
index dd73fe215f..b0ca206bff 100644
--- a/app/jobs/onceoff/retro_grant_anniversary.rb
+++ b/app/jobs/onceoff/retro_grant_anniversary.rb
@@ -8,7 +8,7 @@ module Jobs
 
       # Fill in the years of anniversary badges we missed
       (2..3).each do |year|
-        Jobs::GrantAnniversaryBadges.new.execute(start_date: year.years.ago)
+        ::Jobs::GrantAnniversaryBadges.new.execute(start_date: year.years.ago)
       end
     end
   end
diff --git a/app/jobs/regular/notify_mailing_list_subscribers.rb b/app/jobs/regular/notify_mailing_list_subscribers.rb
index ba63d13af2..c4dfacfb32 100644
--- a/app/jobs/regular/notify_mailing_list_subscribers.rb
+++ b/app/jobs/regular/notify_mailing_list_subscribers.rb
@@ -16,7 +16,7 @@ module Jobs
       when SocketError
         RETRY_TIMES[count]
       else
-        Jobs::UserEmail.seconds_to_delay(count)
+        ::Jobs::UserEmail.seconds_to_delay(count)
       end
     end
 
diff --git a/app/jobs/regular/user_email.rb b/app/jobs/regular/user_email.rb
index 5bdea4fb86..dcc0059d9f 100644
--- a/app/jobs/regular/user_email.rb
+++ b/app/jobs/regular/user_email.rb
@@ -189,7 +189,7 @@ module Jobs
       when Net::SMTPServerBusy
         1.hour + (rand(30) * (count + 1))
       else
-        Jobs::UserEmail.seconds_to_delay(count)
+        ::Jobs::UserEmail.seconds_to_delay(count)
       end
     end
 
diff --git a/app/jobs/scheduled/clean_up_deprecated_url_site_settings.rb b/app/jobs/scheduled/clean_up_deprecated_url_site_settings.rb
index 6352c92857..12d947ec21 100644
--- a/app/jobs/scheduled/clean_up_deprecated_url_site_settings.rb
+++ b/app/jobs/scheduled/clean_up_deprecated_url_site_settings.rb
@@ -5,7 +5,7 @@ module Jobs
     every 1.day
 
     def execute(args)
-      Jobs::MigrateUrlSiteSettings::SETTINGS.each do |old_setting, new_setting|
+      ::Jobs::MigrateUrlSiteSettings::SETTINGS.each do |old_setting, new_setting|
         if SiteSetting.where("name = ? AND value IS NOT NULL", new_setting).exists?
           SiteSetting.set(old_setting, nil, warn: false)
           SiteSetting.find_by(name: old_setting).destroy!
diff --git a/app/jobs/scheduled/heartbeat.rb b/app/jobs/scheduled/heartbeat.rb
index 0f0d9fc020..16ab8b77bb 100644
--- a/app/jobs/scheduled/heartbeat.rb
+++ b/app/jobs/scheduled/heartbeat.rb
@@ -7,7 +7,7 @@ module Jobs
     every 3.minute
 
     def execute(args)
-      Jobs.enqueue(:run_heartbeat, {})
+      ::Jobs.enqueue(:run_heartbeat, {})
     end
   end
 end

GitHub sha: 086b4605

1 Like