docbrown/spec/services/search
Daniel Uber c879c5b3d8
Remove slash characters from user name search term (#15867)
* Remove slash characters from user supplied user search input

Prevents an error when the search term includes '\'

    PG::SyntaxError: ERROR:  syntax error in tsquery

https://app.honeybadger.io/projects/66984/faults/79391397

I had originally thought to add this cleanup to Search::Username but
decided to move it as close to the generated (invalid) query as
possible to prevent alternate paths finding their way here.

* Add spec

Since there's no existing tests for the scope - I put the test code on
the caller (Search::Username) rather than the model (User), this seems reasonable.

* When the term is empty (or only slashes) just return null relation

* Handle nil input (search for nothing) correctly

One of the request specs sends a username search with no query, so we
can't call nil.delete or nil.empty?, use blank? of empty?
2021-12-27 12:30:36 -06:00
..
article_spec.rb Search results: prioritize articles titles (#13918) 2021-06-09 14:28:19 +02:00
comment_spec.rb Cleanup search classes and serializers (#13645) 2021-05-05 09:20:59 -04:00
listing_spec.rb ✂✂✂ Remove Connect (#14734) 2021-11-18 08:21:00 -06:00
podcast_episode_spec.rb Cleanup search classes and serializers (#13645) 2021-05-05 09:20:59 -04:00
reading_list_spec.rb Ensuring reading list excludes unpublished articles (#15490) 2021-11-24 13:22:26 -05:00
tag_spec.rb Cleanup search classes and serializers (#13645) 2021-05-05 09:20:59 -04:00
user_spec.rb Cleanup search classes and serializers (#13645) 2021-05-05 09:20:59 -04:00
username_spec.rb Remove slash characters from user name search term (#15867) 2021-12-27 12:30:36 -06:00