Update rubocop to 2.3.1.

Update rubocop to 2.3.1.

diff --git a/Gemfile.lock b/Gemfile.lock
index b460b62..73fba9a 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -359,7 +359,7 @@ GEM
       unicode-display_width (>= 1.4.0, < 2.0)
     rubocop-ast (0.2.0)
       parser (>= 2.7.0.1)
-    rubocop-discourse (2.2.0)
+    rubocop-discourse (2.3.1)
       rubocop (>= 0.69.0)
       rubocop-rspec (>= 1.39.0)
     rubocop-rspec (1.42.0)
diff --git a/app/jobs/base.rb b/app/jobs/base.rb
index da1623f..b693028 100644
--- a/app/jobs/base.rb
+++ b/app/jobs/base.rb
@@ -357,7 +357,7 @@ module Jobs
   end
 
   def self.enqueue_at(datetime, job_name, opts = {})
-    secs = [(datetime - Time.zone.now).to_i, 0].max
+    secs = [datetime.to_f - Time.zone.now.to_f, 0].max
     enqueue_in(secs, job_name, opts)
   end
 
diff --git a/spec/components/admin_confirmation_spec.rb b/spec/components/admin_confirmation_spec.rb
index 749c566..1474052 100644
--- a/spec/components/admin_confirmation_spec.rb
+++ b/spec/components/admin_confirmation_spec.rb
@@ -33,8 +33,10 @@ describe AdminConfirmation do
       expect(ac.performed_by).to eq(admin)
       expect(ac.target_user).to eq(user)
       expect(ac.token).to eq(@token)
-      Jobs.expects(:enqueue).with(:send_system_message, user_id: user.id, message_type: 'welcome_staff', message_options: { role: :admin })
-      ac.email_confirmed!
+
+      expect_enqueued_with(job: :send_system_message, args: { user_id: user.id, message_type: 'welcome_staff', message_options: { role: :admin } }) do
+        ac.email_confirmed!
+      end
 
       user.reload
       expect(user.admin?).to eq(true)
diff --git a/spec/components/cooked_post_processor_spec.rb b/spec/components/cooked_post_processor_spec.rb
index 9164a7a..a4b9c2b 100644
--- a/spec/components/cooked_post_processor_spec.rb
+++ b/spec/components/cooked_post_processor_spec.rb
@@ -1491,19 +1491,22 @@ describe CookedPostProcessor do
       end
 
       context "and there is enough disk space" do
-        before { cpp.expects(:disable_if_low_on_disk_space) }
+        before { cpp.expects(:disable_if_low_on_disk_space).at_least_once }
 
         context "and the post has been updated by an actual user" do
 
           before { post.id = 42 }
 
           it "ensures only one job is scheduled right after the editing_grace_period" do
+            freeze_time
+
             Jobs.expects(:cancel_scheduled_job).with(:pull_hotlinked_images, post_id: post.id).once
 
             delay = SiteSetting.editing_grace_period + 1
-            Jobs.expects(:enqueue_in).with(delay.seconds, :pull_hotlinked_images, post_id: post.id).once
 
-            cpp.pull_hotlinked_images
+            expect_enqueued_with(job: :pull_hotlinked_images, args: { post_id: post.id }, at: Time.zone.now + delay.seconds) do
+              cpp.pull_hotlinked_images
+            end
           end
 
         end
diff --git a/spec/components/discourse_updates_spec.rb b/spec/components/discourse_updates_spec.rb
index 8e9ef25..4b83510 100644
--- a/spec/components/discourse_updates_spec.rb
+++ b/spec/components/discourse_updates_spec.rb
@@ -76,8 +76,9 @@ describe DiscourseUpdates do
       end
 
       it 'queues a version check' do
-        Jobs.expects(:enqueue).with(:version_check, anything)
-        subject
+        expect_enqueued_with(job: :version_check) do
+          subject
+        end
       end
     end
 
@@ -86,8 +87,9 @@ describe DiscourseUpdates do
     context 'old version check data' do
       shared_examples "queue version check and report that version is ok" do
         it 'queues a version check' do
-          Jobs.expects(:enqueue).with(:version_check, anything)
-          subject
+          expect_enqueued_with(job: :version_check) do
+            subject
+          end
         end
 
         it 'reports 0 missing versions' do
@@ -118,8 +120,9 @@ describe DiscourseUpdates do
 
     shared_examples "when last_installed_version is old" do
       it 'queues a version check' do
-        Jobs.expects(:enqueue).with(:version_check, anything)
-        subject
+        expect_enqueued_with(job: :version_check) do
+          subject
+        end
       end
 
       it 'reports 0 missing versions' do
diff --git a/spec/components/email/processor_spec.rb b/spec/components/email/processor_spec.rb
index 8a4a5ea..85d4148 100644
--- a/spec/components/email/processor_spec.rb
+++ b/spec/components/email/processor_spec.rb
@@ -59,13 +59,15 @@ describe Email::Processor do
     end
 
     it "enqueues a background job by default" do
-      Jobs.expects(:enqueue).with(:process_email, mail: mail)
-      Email::Processor.process!(mail, retry_on_rate_limit: true)
+      expect_enqueued_with(job: :process_email, args: { mail: mail }) do
+        Email::Processor.process!(mail, retry_on_rate_limit: true)
+      end
     end
 
     it "doesn't enqueue a background job when retry is disabled" do
-      Jobs.expects(:enqueue).with(:process_email, mail: mail).never
-      expect { Email::Processor.process!(mail, retry_on_rate_limit: false) }.to raise_error(limit_exceeded)
+      expect_not_enqueued_with(job: :process_email, args: { mail: mail }) do
+        expect { Email::Processor.process!(mail, retry_on_rate_limit: false) }.to raise_error(limit_exceeded)
+      end
     end
 
   end
diff --git a/spec/components/email_updater_spec.rb b/spec/components/email_updater_spec.rb
index 3b110a7..4fd6cba 100644
--- a/spec/components/email_updater_spec.rb
+++ b/spec/components/email_updater_spec.rb
@@ -22,21 +22,29 @@ describe EmailUpdater do
     let(:updater) { EmailUpdater.new(guardian: admin.guardian, user: user) }
 
     def expect_old_email_job
-      Jobs.expects(:enqueue).with(:critical_user_email, has_entries(to_address: old_email, type: :notify_old_email, user_id: user.id))
+      expect_enqueued_with(job: :critical_user_email, args: { to_address: old_email, type: :notify_old_email, user_id: user.id }) do
+        yield
+      end
     end
 
     def expect_forgot_password_job
-      Jobs.expects(:enqueue).with(:critical_user_email, has_entries(type: :forgot_password, user_id: user.id))
+      expect_enqueued_with(job: :critical_user_email, args: { type: :forgot_password, user_id: user.id }) do
+        yield
+      end
     end
 
     context "for a regular user" do
       let(:user) { Fabricate(:user, email: old_email) }
 
       it "does not send an email to the user for them to confirm their new email but still sends the notification to the old email" do
-        Jobs.expects(:enqueue).with(:critical_user_email, has_entries(type: :confirm_new_email, to_address: new_email)).never
-        expect_old_email_job
-        expect_forgot_password_job
-        updater.change_to(new_email)
+        expect_old_email_job do
+          expect_forgot_password_job do
+            updater.change_to(new_email)
+
+            expect(Jobs::CriticalUserEmail.jobs.size).to eq(2)
+          end
+        end
+
       end
 
       it "creates a change request authorizing the new email and immediately confirms it " do
@@ -46,9 +54,11 @@ describe EmailUpdater do
       end
 
       it "sends a reset password email to the user so they can set a password for their new email" do
-        expect_old_email_job
-        expect_forgot_password_job
-        updater.change_to(new_email)
+        expect_old_email_job do
+          expect_forgot_password_job do
+            updater.change_to(new_email)
+          end
+        end
       end
     end
 
@@ -56,8 +66,10 @@ describe EmailUpdater do
       let(:user) { Fabricate(:moderator, email: old_email) }
 
       before do
-        Jobs.expects(:enqueue).once.with(:critical_user_email, has_entries(type: :confirm_old_email, to_address: old_email))
-        updater.change_to(new_email)
+        expect_enqueued_with(job: :critical_user_email, args: { type: :confirm_old_email, to_address: old_email }) do
+          updater.change_to(new_email)
+        end
+
         @change_req = user.email_change_requests.first
       end
 
@@ -83,8 +95,11 @@ describe EmailUpdater do

[... diff too long, it was truncated ...]

GitHub sha: c6202af0