@@ -295,7 +295,9 class ProjectsController < ApplicationController | |||||
295 | @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1') |
|
295 | @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1') | |
296 | project_ids = @with_subprojects ? @project.self_and_descendants.collect(&:id) : [@project.id] |
|
296 | project_ids = @with_subprojects ? @project.self_and_descendants.collect(&:id) : [@project.id] | |
297 |
|
297 | |||
298 |
@versions = @project.shared_versions |
|
298 | @versions = @project.shared_versions || [] | |
|
299 | @versions += @project.rolled_up_versions.visible if @with_subprojects | |||
|
300 | @versions = @versions.uniq.sort | |||
299 | @versions.reject! {|version| version.closed? || version.completed? } unless params[:completed] |
|
301 | @versions.reject! {|version| version.closed? || version.completed? } unless params[:completed] | |
300 |
|
302 | |||
301 | @issues_by_version = {} |
|
303 | @issues_by_version = {} |
@@ -336,6 +336,13 class Project < ActiveRecord::Base | |||||
336 | end |
|
336 | end | |
337 | end |
|
337 | end | |
338 | end |
|
338 | end | |
|
339 | ||||
|
340 | # Returns a scope of the Versions on subprojects | |||
|
341 | def rolled_up_versions | |||
|
342 | @rolled_up_versions ||= | |||
|
343 | Version.scoped(:include => :project, | |||
|
344 | :conditions => ["#{Project.table_name}.lft >= ? AND #{Project.table_name}.rgt <= ? AND #{Project.table_name}.status = #{STATUS_ACTIVE}", lft, rgt]) | |||
|
345 | end | |||
339 |
|
346 | |||
340 | # Returns a scope of the Versions used by the project |
|
347 | # Returns a scope of the Versions used by the project | |
341 | def shared_versions |
|
348 | def shared_versions |
@@ -364,12 +364,14 class ProjectsControllerTest < ActionController::TestCase | |||||
364 | end |
|
364 | end | |
365 |
|
365 | |||
366 | def test_roadmap_showing_subprojects_versions |
|
366 | def test_roadmap_showing_subprojects_versions | |
|
367 | @subproject_version = Version.generate!(:project => Project.find(3)) | |||
367 | get :roadmap, :id => 1, :with_subprojects => 1 |
|
368 | get :roadmap, :id => 1, :with_subprojects => 1 | |
368 | assert_response :success |
|
369 | assert_response :success | |
369 | assert_template 'roadmap' |
|
370 | assert_template 'roadmap' | |
370 | assert_not_nil assigns(:versions) |
|
371 | assert_not_nil assigns(:versions) | |
371 | # Version on subproject appears |
|
372 | ||
372 | assert assigns(:versions).include?(Version.find(4)) |
|
373 | assert assigns(:versions).include?(Version.find(4)), "Shared version not found" | |
|
374 | assert assigns(:versions).include?(@subproject_version), "Subproject version not found" | |||
373 | end |
|
375 | end | |
374 | def test_project_activity |
|
376 | def test_project_activity | |
375 | get :activity, :id => 1, :with_subprojects => 0 |
|
377 | get :activity, :id => 1, :with_subprojects => 0 |
@@ -360,6 +360,59 class ProjectTest < ActiveSupport::TestCase | |||||
360 |
|
360 | |||
361 | assert_equal [1,2], parent.rolled_up_trackers.collect(&:id) |
|
361 | assert_equal [1,2], parent.rolled_up_trackers.collect(&:id) | |
362 | end |
|
362 | end | |
|
363 | ||||
|
364 | context "#rolled_up_versions" do | |||
|
365 | setup do | |||
|
366 | @project = Project.generate! | |||
|
367 | @parent_version_1 = Version.generate!(:project => @project) | |||
|
368 | @parent_version_2 = Version.generate!(:project => @project) | |||
|
369 | end | |||
|
370 | ||||
|
371 | should "include the versions for the current project" do | |||
|
372 | assert_same_elements [@parent_version_1, @parent_version_2], @project.rolled_up_versions | |||
|
373 | end | |||
|
374 | ||||
|
375 | should "include versions for a subproject" do | |||
|
376 | @subproject = Project.generate! | |||
|
377 | @subproject.set_parent!(@project) | |||
|
378 | @subproject_version = Version.generate!(:project => @subproject) | |||
|
379 | ||||
|
380 | assert_same_elements [ | |||
|
381 | @parent_version_1, | |||
|
382 | @parent_version_2, | |||
|
383 | @subproject_version | |||
|
384 | ], @project.rolled_up_versions | |||
|
385 | end | |||
|
386 | ||||
|
387 | should "include versions for a sub-subproject" do | |||
|
388 | @subproject = Project.generate! | |||
|
389 | @subproject.set_parent!(@project) | |||
|
390 | @sub_subproject = Project.generate! | |||
|
391 | @sub_subproject.set_parent!(@subproject) | |||
|
392 | @sub_subproject_version = Version.generate!(:project => @sub_subproject) | |||
|
393 | ||||
|
394 | @project.reload | |||
|
395 | ||||
|
396 | assert_same_elements [ | |||
|
397 | @parent_version_1, | |||
|
398 | @parent_version_2, | |||
|
399 | @sub_subproject_version | |||
|
400 | ], @project.rolled_up_versions | |||
|
401 | end | |||
|
402 | ||||
|
403 | ||||
|
404 | should "only check active projects" do | |||
|
405 | @subproject = Project.generate! | |||
|
406 | @subproject.set_parent!(@project) | |||
|
407 | @subproject_version = Version.generate!(:project => @subproject) | |||
|
408 | assert @subproject.archive | |||
|
409 | ||||
|
410 | @project.reload | |||
|
411 | ||||
|
412 | assert !@subproject.active? | |||
|
413 | assert_same_elements [@parent_version_1, @parent_version_2], @project.rolled_up_versions | |||
|
414 | end | |||
|
415 | end | |||
363 |
|
416 | |||
364 | def test_shared_versions_none_sharing |
|
417 | def test_shared_versions_none_sharing | |
365 | p = Project.find(5) |
|
418 | p = Project.find(5) |
General Comments 0
You need to be logged in to leave comments.
Login now