]> source.dussan.org Git - redmine.git/commitdiff
Ignore from search module params sent with empty values (#34615).
authorGo MAEDA <maeda@farend.jp>
Sat, 6 Feb 2021 05:03:23 +0000 (05:03 +0000)
committerGo MAEDA <maeda@farend.jp>
Sat, 6 Feb 2021 05:03:23 +0000 (05:03 +0000)
Patch by Marius BALTEANU.

git-svn-id: http://svn.redmine.org/redmine/trunk@20738 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/search_controller.rb
test/functional/search_controller_test.rb

index d6bb2dd94204495f1fd3a88347a8907c1f980139..1a4a12fcc20a8cce4e554491be2255305a712af3 100644 (file)
@@ -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(
index 24468eaa1a4c0a1dcac1ecbc9553b2492a96d9f4..c31abb52b5cd15cd666fbe14452e628e0c5023aa 100644 (file)
@@ -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