From: Go MAEDA Date: Sat, 6 Feb 2021 05:03:23 +0000 (+0000) Subject: Ignore from search module params sent with empty values (#34615). X-Git-Tag: 4.2.0~94 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=cbac878ee441b7fd0af891b7c0e310cce6938c4b;p=redmine.git Ignore from search module params sent with empty values (#34615). Patch by Marius BALTEANU. git-svn-id: http://svn.redmine.org/redmine/trunk@20738 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index d6bb2dd94..1a4a12fcc 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -63,7 +63,7 @@ class SearchController < ApplicationController @object_types = @object_types.select {|o| User.current.allowed_to?("view_#{o}".to_sym, projects_to_search)} end - @scope = @object_types.select {|t| params[t]} + @scope = @object_types.select {|t| params[t].present?} @scope = @object_types if @scope.empty? fetcher = Redmine::Search::Fetcher.new( diff --git a/test/functional/search_controller_test.rb b/test/functional/search_controller_test.rb index 24468eaa1..c31abb52b 100644 --- a/test/functional/search_controller_test.rb +++ b/test/functional/search_controller_test.rb @@ -428,4 +428,19 @@ class SearchControllerTest < Redmine::ControllerTest assert_select 'dd span.highlight', :text => 'highlighted' end end + + def test_search_should_exclude_empty_modules_params + @request.session[:user_id] = 1 + + get :index, params: { + q: "private", + scope: "all", + issues: "1", + projects: nil + } + + assert_response :success + + assert_select '#search-results dt.project', 0 + end end