Merge pull request #3897 from Keirua/fix/crash-empty-query-search
no crash when q is missing on RechercheController::index
This commit is contained in:
commit
ce5ee0b766
2 changed files with 13 additions and 1 deletions
|
@ -38,7 +38,8 @@ class DossierSearchService
|
|||
end
|
||||
|
||||
def self.to_tsquery(search_terms)
|
||||
search_terms.strip
|
||||
(search_terms || "")
|
||||
.strip
|
||||
.gsub(/['?\\:&|!<>\(\)]/, "") # drop disallowed characters
|
||||
.split(/\s+/) # split words
|
||||
.map { |x| "#{x}:*" } # enable prefix matching
|
||||
|
|
|
@ -48,5 +48,16 @@ describe Gestionnaires::RechercheController, type: :controller do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'with no query param it does not crash' do
|
||||
subject { get :index, params: {} }
|
||||
|
||||
it { is_expected.to have_http_status(200) }
|
||||
|
||||
it 'returns 0 dossier' do
|
||||
subject
|
||||
expect(assigns(:dossiers).count).to eq(0)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue