@@ -225,12 +225,12 class Project < ActiveRecord::Base | |||
|
225 | 225 | end |
|
226 | 226 | end |
|
227 | 227 | |
|
228 | # Returns an array of the trackers used by the project and its sub projects | |
|
228 | # Returns an array of the trackers used by the project and its active sub projects | |
|
229 | 229 | def rolled_up_trackers |
|
230 | 230 | @rolled_up_trackers ||= |
|
231 | 231 | Tracker.find(:all, :include => :projects, |
|
232 | 232 | :select => "DISTINCT #{Tracker.table_name}.*", |
|
233 | :conditions => ["#{Project.table_name}.lft >= ? AND #{Project.table_name}.rgt <= ?", lft, rgt], | |
|
233 | :conditions => ["#{Project.table_name}.lft >= ? AND #{Project.table_name}.rgt <= ? AND #{Project.table_name}.status = #{STATUS_ACTIVE}", lft, rgt], | |
|
234 | 234 | :order => "#{Tracker.table_name}.position") |
|
235 | 235 | end |
|
236 | 236 |
@@ -198,6 +198,16 class ProjectTest < Test::Unit::TestCase | |||
|
198 | 198 | assert_equal [2, 3], child.rolled_up_trackers.collect(&:id) |
|
199 | 199 | end |
|
200 | 200 | |
|
201 | def test_rolled_up_trackers_should_ignore_archived_subprojects | |
|
202 | parent = Project.find(1) | |
|
203 | parent.trackers = Tracker.find([1,2]) | |
|
204 | child = parent.children.find(3) | |
|
205 | child.trackers = Tracker.find([1,3]) | |
|
206 | parent.children.each(&:archive) | |
|
207 | ||
|
208 | assert_equal [1,2], parent.rolled_up_trackers.collect(&:id) | |
|
209 | end | |
|
210 | ||
|
201 | 211 | def test_next_identifier |
|
202 | 212 | ProjectCustomField.delete_all |
|
203 | 213 | Project.create!(:name => 'last', :identifier => 'p2008040') |
General Comments 0
You need to be logged in to leave comments.
Login now