summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2009-01-25 11:15:28 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2009-01-25 11:15:28 +0000
commit90c742e4f193642211c39c0ba862c9f8cf1875e8 (patch)
tree9297167d2bb208128324908567faebfc2f90c8fc
parent97e31c40261491df8afd0297dd41050d165881ac (diff)
downloadredmine-90c742e4f193642211c39c0ba862c9f8cf1875e8.tar.gz
redmine-90c742e4f193642211c39c0ba862c9f8cf1875e8.zip
Ignore archived subprojects in Project#rolled_up_trackers (#2550).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2311 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/models/project.rb4
-rw-r--r--test/unit/project_test.rb10
2 files changed, 12 insertions, 2 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 8e4bd78e1..f40bcb603 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -225,12 +225,12 @@ class Project < ActiveRecord::Base
end
end
- # Returns an array of the trackers used by the project and its sub projects
+ # Returns an array of the trackers used by the project and its active sub projects
def rolled_up_trackers
@rolled_up_trackers ||=
Tracker.find(:all, :include => :projects,
:select => "DISTINCT #{Tracker.table_name}.*",
- :conditions => ["#{Project.table_name}.lft >= ? AND #{Project.table_name}.rgt <= ?", lft, rgt],
+ :conditions => ["#{Project.table_name}.lft >= ? AND #{Project.table_name}.rgt <= ? AND #{Project.table_name}.status = #{STATUS_ACTIVE}", lft, rgt],
:order => "#{Tracker.table_name}.position")
end
diff --git a/test/unit/project_test.rb b/test/unit/project_test.rb
index 6a143fae9..94177f433 100644
--- a/test/unit/project_test.rb
+++ b/test/unit/project_test.rb
@@ -198,6 +198,16 @@ class ProjectTest < Test::Unit::TestCase
assert_equal [2, 3], child.rolled_up_trackers.collect(&:id)
end
+ def test_rolled_up_trackers_should_ignore_archived_subprojects
+ parent = Project.find(1)
+ parent.trackers = Tracker.find([1,2])
+ child = parent.children.find(3)
+ child.trackers = Tracker.find([1,3])
+ parent.children.each(&:archive)
+
+ assert_equal [1,2], parent.rolled_up_trackers.collect(&:id)
+ end
+
def test_next_identifier
ProjectCustomField.delete_all
Project.create!(:name => 'last', :identifier => 'p2008040')