Skip to content

Commit cbac878

Browse files
committed
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
1 parent 252c28f commit cbac878

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

app/controllers/search_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def index
6363
@object_types = @object_types.select {|o| User.current.allowed_to?("view_#{o}".to_sym, projects_to_search)}
6464
end
6565

66-
@scope = @object_types.select {|t| params[t]}
66+
@scope = @object_types.select {|t| params[t].present?}
6767
@scope = @object_types if @scope.empty?
6868

6969
fetcher = Redmine::Search::Fetcher.new(

test/functional/search_controller_test.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,4 +428,19 @@ def test_keywords_should_be_highlighted
428428
assert_select 'dd span.highlight', :text => 'highlighted'
429429
end
430430
end
431+
432+
def test_search_should_exclude_empty_modules_params
433+
@request.session[:user_id] = 1
434+
435+
get :index, params: {
436+
q: "private",
437+
scope: "all",
438+
issues: "1",
439+
projects: nil
440+
}
441+
442+
assert_response :success
443+
444+
assert_select '#search-results dt.project', 0
445+
end
431446
end

0 commit comments

Comments
 (0)