Skip to content

Commit

Permalink
Fix invalid arguments passed to find_by.
Browse files Browse the repository at this point in the history
  • Loading branch information
tgxworld committed Apr 30, 2019
1 parent 7b74329 commit 00a9cb1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion jobs/regular/remind_user.rb
Expand Up @@ -3,7 +3,7 @@ class RemindUser < Jobs::Base
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)
Expand Down
11 changes: 11 additions & 0 deletions 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

0 comments on commit 00a9cb1

Please sign in to comment.