From 8fb21644bfd1ebf7c48b47c3a6fa71640f7c0443 Mon Sep 17 00:00:00 2001 From: Marius BALTEANU Date: Mon, 25 Jan 2021 01:14:22 +0200 Subject: [PATCH] Ignore from search module params sent with empty values --- app/controllers/search_controller.rb | 2 +- test/functional/search_controller_test.rb | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) 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 -- 2.22.0