Fix invalid arguments passed to `find_by`.

approved
#1

Fix invalid arguments passed to find_by.

diff --git a/jobs/regular/remind_user.rb b/jobs/regular/remind_user.rb
index 9a8cd78..1fe2728 100644
--- a/jobs/regular/remind_user.rb
+++ b/jobs/regular/remind_user.rb
@@ -3,7 +3,7 @@ module Jobs
     sidekiq_options queue: 'low'
 
     def execute(args)
-      user = User.find_by(args[:user_id])
+      user = User.find_by(id: args[:user_id])
       raise Discourse::InvalidParameters.new(:user_id) if user.nil?
 
       PendingAssignsReminder.new.remind(user)
diff --git a/spec/jobs/regular/remind_user_spec.rb b/spec/jobs/regular/remind_user_spec.rb
new file mode 100644
index 0000000..5f9d93d
--- /dev/null
+++ b/spec/jobs/regular/remind_user_spec.rb
@@ -0,0 +1,11 @@
+require 'rails_helper'
+
+RSpec.describe Jobs::RemindUser do
+  describe '#execute' do
+    it "should raise the right error when user_id is invalid" do
+      expect do
+        described_class.new.execute({})
+      end.to raise_error(Discourse::InvalidParameters)
+    end
+  end
+end

GitHub sha: 00a9cb17

2 Likes
Approved #2