Skip to content

Commit

Permalink
Fix error when calling the users API with no parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Dantemss committed Oct 21, 2024
1 parent a9dfa58 commit 25ee672
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ DEPENDENCIES
jobba
jquery-rails
json-jwt
keyword_search (~> 1.5.0)
keyword_search
knockoutjs-rails
launchy
lev!
Expand Down
2 changes: 1 addition & 1 deletion app/routines/search_users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def exec(query, options={})
]
)

KeywordSearch.search(query) do |with|
KeywordSearch.search(query || '') do |with|

with.default_keyword :any

Expand Down
6 changes: 6 additions & 0 deletions spec/controllers/api/v1/users_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 25ee672

Please sign in to comment.