From 58efae893c3861e9a68d50ecf785402eec7bf308 Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Mon, 8 Feb 2021 06:24:24 +0000 Subject: [PATCH] Merged r20738 from trunk to 4.0-stable (#34615). git-svn-id: http://svn.redmine.org/redmine/branches/4.0-stable@20741 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- 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 e192b855b..4fede80a8 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -62,7 +62,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 f5b52b2b4..8754f82a0 100644 --- a/test/functional/search_controller_test.rb +++ b/test/functional/search_controller_test.rb @@ -426,4 +426,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