don't 500 when passing nothing into user_search

test plan
 - specs should pass

fixes VICE-2057
flag=none

Change-Id: Ieafc0fbf2e0665ee0fb8ba89359329e14f18a2c6
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/273090
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Drake Harper <drake.harper@instructure.com>
QA-Review: Drake Harper <drake.harper@instructure.com>
Product-Review: Drake Harper <drake.harper@instructure.com>
This commit is contained in:
Rob Orton 2021-09-07 16:09:52 -06:00
parent 021d3958ea
commit d822ac00cc
2 changed files with 8 additions and 1 deletions

View File

@ -53,6 +53,7 @@ class UserList
@initial_type = initial_type
@search_method = (@root_account.open_registration? ? :open : :closed) if @search_method == :infer
@current_user = current_user
list_in ||= ''
parse_list(list_in)
resolve
end
@ -217,7 +218,7 @@ class UserList
associated_shards << @root_account.shard
Shard.partition_by_shard(all_account_ids) do |account_ids|
next if GlobalLookups.enabled? && !associated_shards.include?(Shard.current)
pseudos = Pseudonym.active
.select('path AS address, users.name AS name, communication_channels.user_id AS user_id, communication_channels.workflow_state AS workflow_state')
.joins(:user => :communication_channels)

View File

@ -40,6 +40,12 @@ describe UserList do
expect(ul.addresses.map{|x| [x[:name], x[:address]]}).to eq [["senor molé", "blah@instructure.com"]]
end
it "should not cause error with nothing past to it" do
ul = UserList.new(nil)
expect(ul.errors).to eq []
expect(ul.addresses.map{|x| [x[:name], x[:address]]}).to eq []
end
it "should find by SMS number" do
user_with_pseudonym(:name => "JT", :active_all => 1)
communication_channel(@user, {username: '8015555555@txt.att.net', path_type: 'sms', active_cc: true})