Show subproject versions on the Roadmap.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3760 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
e5ac73b7dc
commit
f3cc84b343
|
@ -295,7 +295,9 @@ class ProjectsController < ApplicationController
|
|||
@with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1')
|
||||
project_ids = @with_subprojects ? @project.self_and_descendants.collect(&:id) : [@project.id]
|
||||
|
||||
@versions = @project.shared_versions.sort
|
||||
@versions = @project.shared_versions || []
|
||||
@versions += @project.rolled_up_versions.visible if @with_subprojects
|
||||
@versions = @versions.uniq.sort
|
||||
@versions.reject! {|version| version.closed? || version.completed? } unless params[:completed]
|
||||
|
||||
@issues_by_version = {}
|
||||
|
|
|
@ -336,6 +336,13 @@ class Project < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Returns a scope of the Versions on subprojects
|
||||
def rolled_up_versions
|
||||
@rolled_up_versions ||=
|
||||
Version.scoped(:include => :project,
|
||||
:conditions => ["#{Project.table_name}.lft >= ? AND #{Project.table_name}.rgt <= ? AND #{Project.table_name}.status = #{STATUS_ACTIVE}", lft, rgt])
|
||||
end
|
||||
|
||||
# Returns a scope of the Versions used by the project
|
||||
def shared_versions
|
||||
|
|
|
@ -364,12 +364,14 @@ class ProjectsControllerTest < ActionController::TestCase
|
|||
end
|
||||
|
||||
def test_roadmap_showing_subprojects_versions
|
||||
@subproject_version = Version.generate!(:project => Project.find(3))
|
||||
get :roadmap, :id => 1, :with_subprojects => 1
|
||||
assert_response :success
|
||||
assert_template 'roadmap'
|
||||
assert_not_nil assigns(:versions)
|
||||
# Version on subproject appears
|
||||
assert assigns(:versions).include?(Version.find(4))
|
||||
|
||||
assert assigns(:versions).include?(Version.find(4)), "Shared version not found"
|
||||
assert assigns(:versions).include?(@subproject_version), "Subproject version not found"
|
||||
end
|
||||
def test_project_activity
|
||||
get :activity, :id => 1, :with_subprojects => 0
|
||||
|
|
|
@ -360,6 +360,59 @@ class ProjectTest < ActiveSupport::TestCase
|
|||
|
||||
assert_equal [1,2], parent.rolled_up_trackers.collect(&:id)
|
||||
end
|
||||
|
||||
context "#rolled_up_versions" do
|
||||
setup do
|
||||
@project = Project.generate!
|
||||
@parent_version_1 = Version.generate!(:project => @project)
|
||||
@parent_version_2 = Version.generate!(:project => @project)
|
||||
end
|
||||
|
||||
should "include the versions for the current project" do
|
||||
assert_same_elements [@parent_version_1, @parent_version_2], @project.rolled_up_versions
|
||||
end
|
||||
|
||||
should "include versions for a subproject" do
|
||||
@subproject = Project.generate!
|
||||
@subproject.set_parent!(@project)
|
||||
@subproject_version = Version.generate!(:project => @subproject)
|
||||
|
||||
assert_same_elements [
|
||||
@parent_version_1,
|
||||
@parent_version_2,
|
||||
@subproject_version
|
||||
], @project.rolled_up_versions
|
||||
end
|
||||
|
||||
should "include versions for a sub-subproject" do
|
||||
@subproject = Project.generate!
|
||||
@subproject.set_parent!(@project)
|
||||
@sub_subproject = Project.generate!
|
||||
@sub_subproject.set_parent!(@subproject)
|
||||
@sub_subproject_version = Version.generate!(:project => @sub_subproject)
|
||||
|
||||
@project.reload
|
||||
|
||||
assert_same_elements [
|
||||
@parent_version_1,
|
||||
@parent_version_2,
|
||||
@sub_subproject_version
|
||||
], @project.rolled_up_versions
|
||||
end
|
||||
|
||||
|
||||
should "only check active projects" do
|
||||
@subproject = Project.generate!
|
||||
@subproject.set_parent!(@project)
|
||||
@subproject_version = Version.generate!(:project => @subproject)
|
||||
assert @subproject.archive
|
||||
|
||||
@project.reload
|
||||
|
||||
assert !@subproject.active?
|
||||
assert_same_elements [@parent_version_1, @parent_version_2], @project.rolled_up_versions
|
||||
end
|
||||
end
|
||||
|
||||
def test_shared_versions_none_sharing
|
||||
p = Project.find(5)
|
||||
|
|
Loading…
Reference in New Issue