]> source.dussan.org Git - redmine.git/commitdiff
Filter after parent project (#29482).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 19 Oct 2019 11:38:15 +0000 (11:38 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 19 Oct 2019 11:38:15 +0000 (11:38 +0000)
Patch by Marius BALTEANU.

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

app/models/project_query.rb
test/functional/projects_controller_test.rb

index 41ab49363664e82d7ab460b3b34e1f13fb399a33..71878c2a80c7beae5e812b5164443d01a8a2473e 100644 (file)
@@ -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"]]
index fc4d66523107745a44e35610d8484e5f529e49cc..3f4dd696775e834eb73cf23da7db0a00d7ba0654 100644 (file)
@@ -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',