From 9c091d5d96a642f487630e8fdd9503b0e500f9b5 Mon Sep 17 00:00:00 2001 From: Marius BALTEANU Date: Sun, 23 Sep 2018 08:57:18 +0000 Subject: [PATCH 3/6] Filter after parent project --- app/models/project_query.rb | 3 +++ test/functional/projects_controller_test.rb | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/app/models/project_query.rb b/app/models/project_query.rb index 41ab49363..71878c2a8 100644 --- a/app/models/project_query.rb +++ b/app/models/project_query.rb @@ -37,6 +37,9 @@ class ProjectQuery < Query ) add_available_filter "name", :type => :text add_available_filter "description", :type => :text + add_available_filter("parent_id", + :type => :list_subprojects, :values => lambda { project_values }, :label => :field_parent + ) add_available_filter "is_public", :type => :list, :values => [[l(:general_text_yes), "1"], [l(:general_text_no), "0"]] diff --git a/test/functional/projects_controller_test.rb b/test/functional/projects_controller_test.rb index 41ed49785..5d9a5b7f9 100644 --- a/test/functional/projects_controller_test.rb +++ b/test/functional/projects_controller_test.rb @@ -75,6 +75,25 @@ class ProjectsControllerTest < Redmine::ControllerTest end end + def test_index_with_subproject_filter + @request.session[:user_id] = 1 + + get :index, :params => { + :f => ['parent_id'], + :op => {'parent_id' => '='}, + :v => {'parent_id' => ['1']} + } + + assert_response :success + + assert_select 'div#projects-index ul' do + assert_select 'a.project', 3 + assert_select 'a', :text => 'eCookbook Subproject 1' + assert_select 'a', :text => 'eCookbook Subproject 2' + assert_select 'a', :text => 'Private child of eCookbook' + end + end + def test_autocomplete_js get :autocomplete, :params => { :format => 'js', -- 2.22.0