diff --git a/Gemfile b/Gemfile index 94ac8c47d..79c7a5fcb 100644 --- a/Gemfile +++ b/Gemfile @@ -123,7 +123,7 @@ gem 'delayed_job_heartbeat_plugin' gem 'representable' # Keyword search -gem 'keyword_search', '~> 1.5.0' +gem 'keyword_search' # ToS/PP management gem 'fine_print', github: 'lml/fine_print', ref: '636023f68e95196dffaf295bfad3ad8051c23542' diff --git a/Gemfile.lock b/Gemfile.lock index 9dd659a56..09e80a2df 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -863,7 +863,7 @@ DEPENDENCIES jobba jquery-rails json-jwt - keyword_search (~> 1.5.0) + keyword_search knockoutjs-rails launchy lev! diff --git a/app/routines/search_users.rb b/app/routines/search_users.rb index cb685ff83..49061c24c 100644 --- a/app/routines/search_users.rb +++ b/app/routines/search_users.rb @@ -47,7 +47,7 @@ def exec(query, options={}) ] ) - KeywordSearch.search(query) do |with| + KeywordSearch.search(query || '') do |with| with.default_keyword :any diff --git a/spec/controllers/api/v1/users_controller_spec.rb b/spec/controllers/api/v1/users_controller_spec.rb index af95dfdf8..75880e7cb 100644 --- a/spec/controllers/api/v1/users_controller_spec.rb +++ b/spec/controllers/api/v1/users_controller_spec.rb @@ -58,6 +58,12 @@ let(:is_not_gdpr_location) { nil } context "index" do + it "does not explode when called without params" do + api_get :index, trusted_application_token + expect(response.code).to eq('200') + expect(response.body_as_hash).to match({ total_count: User.count, items: [] }) + end + it "returns a single result well" do api_get :index, trusted_application_token, params: { q: 'first_name:bob last_name:Michaels' } expect(response.code).to eq('200')