From 2b2847a42f423355365bf01c50c05671e6a6ed3a Mon Sep 17 00:00:00 2001 From: Marius BALTEANU Date: Wed, 5 Dec 2018 21:58:16 +0000 Subject: [PATCH] Include closed projects in search for scope subprojects (#28636) --- app/controllers/search_controller.rb | 2 +- test/functional/search_controller_test.rb | 40 +++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 00b0238..744c3a3 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -49,7 +49,7 @@ class SearchController < ApplicationController when 'my_projects' User.current.projects when 'subprojects' - @project ? (@project.self_and_descendants.active.to_a) : nil + @project ? (@project.self_and_descendants.to_a) : nil else @project end diff --git a/test/functional/search_controller_test.rb b/test/functional/search_controller_test.rb index aace89a..f5b52b2 100644 --- a/test/functional/search_controller_test.rb +++ b/test/functional/search_controller_test.rb @@ -338,6 +338,46 @@ class SearchControllerTest < Redmine::ControllerTest assert_response 404 end + def test_search_should_include_closed_projects + @request.session[:user_id] = 1 + + project = Project.find(5) + project.close + project.save + + # scope all + get :index, :params => {:q => 'Issue of a private subproject', :scope => 'all'} + assert_response :success + + assert_select '#search-results' do + assert_select 'dt.issue', :text => /Bug #6/ + end + + # scope my_projects + get :index, :params => {:q => 'Issue of a private subproject', :scope => 'my_projects'} + assert_response :success + + assert_select '#search-results' do + assert_select 'dt.issue', :text => /Bug #6/ + end + + # scope subprojects + get :index, :params => {:id => 1, :q => 'Issue of a private subproject', :scope => 'subprojects'} + assert_response :success + + assert_select '#search-results' do + assert_select 'dt.issue', :text => /Bug #6/ + end + + # scope project + get :index, :params => {:id => 5, :q => 'Issue of a private subproject'} + assert_response :success + + assert_select '#search-results' do + assert_select 'dt.issue', :text => /Bug #6/ + end + end + def test_quick_jump_to_issue # issue of a public project get :index, :params => {:q => "3"} -- 2.1.4