]> source.dussan.org Git - redmine.git/commitdiff
Fix that disabled trackers of subprojects are listed in project overview (#10084).
authorGo MAEDA <maeda@farend.jp>
Sat, 12 Dec 2020 05:40:09 +0000 (05:40 +0000)
committerGo MAEDA <maeda@farend.jp>
Sat, 12 Dec 2020 05:40:09 +0000 (05:40 +0000)
Patch by Yuichi HARADA.

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

app/controllers/projects_controller.rb
test/functional/projects_controller_test.rb

index de05fdb35318eb2dd063bda8ec5297e6ff9efad8..c99be498e1577d9030b4673acc8e45b42e84770f 100644 (file)
@@ -175,9 +175,10 @@ class ProjectsController < ApplicationController
     @principals_by_role = @project.principals_by_role
     @subprojects = @project.children.visible.to_a
     @news = @project.news.limit(5).includes(:author, :project).reorder("#{News.table_name}.created_on DESC").to_a
-    @trackers = @project.rolled_up_trackers.visible
+    with_subprojects = Setting.display_subprojects_issues?
+    @trackers = @project.rolled_up_trackers(with_subprojects).visible
 
-    cond = @project.project_condition(Setting.display_subprojects_issues?)
+    cond = @project.project_condition(with_subprojects)
 
     @open_issues_by_tracker = Issue.visible.open.where(cond).group(:tracker).count
     @total_issues_by_tracker = Issue.visible.where(cond).group(:tracker).count
index c7329b2e58b1b29c838b7b11ba5164465e1c67ea..89945de753372ff07caeaabe9bd5db8335209e61 100644 (file)
@@ -750,6 +750,25 @@ class ProjectsControllerTest < Redmine::ControllerTest
     assert_select 'table.issue-report td.total a', :text => %r{\A[1-9]\d*\z}
   end
 
+  def test_show_should_not_display_subprojects_trackers_when_subprojects_issues_is_not_displayed
+    project = Project.find('ecookbook')
+    tracker = project.trackers.find_by(name: 'Support request')
+    project.trackers.delete(tracker)
+    @request.session[:user_id] = 2
+
+    with_settings :display_subprojects_issues => '1' do
+      get(:show, :params => {:id => 'ecookbook'})
+      assert_response :success
+      assert_select 'table.issue-report td.name', :text => 'Support request', :count => 1
+    end
+
+    with_settings :display_subprojects_issues => '0' do
+      get(:show, :params => {:id => 'ecookbook'})
+      assert_response :success
+      assert_select 'table.issue-report td.name', :text => 'Support request', :count => 0
+    end
+  end
+
   def test_show_should_spent_and_estimated_time
     @request.session[:user_id] = 1
     get(:show, :params => {:id => 'ecookbook'})