Each version of a project can be shared with: * subprojects * projects in the project hierarchy: ancestors + descendants (needs versions management permission on the root project) * projects in the project tree: root project + all its descendants (same as above) * all projects (can be set by admin users only) Notes: * when sharing a version of a private project with others projects, its name will be visible within the other projects * a project with versions used by non descendant projects can not be archived git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3123 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
1 parent
e178123569
commit
5f8e9d7118
40 files changed
+659
-75
No files matched your search
+101
-11
@@ -18,10 +18,7 @@
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
|
||||
class ProjectTest < ActiveSupport::TestCase
|
||||
fixtures :projects, :enabled_modules,
|
||||
:issues, :issue_statuses, :journals, :journal_details,
|
||||
:users, :members, :member_roles, :roles, :projects_trackers, :trackers, :boards,
|
||||
:queries
|
||||
fixtures :all
|
||||
|
||||
def setup
|
||||
@ecookbook = Project.find(1)
|
||||
@@ -111,6 +108,17 @@ class ProjectTest < ActiveSupport::TestCase
|
||||
assert @ecookbook.descendants.active.empty?
|
||||
end
|
||||
|
||||
def test_archive_should_fail_if_versions_are_used_by_non_descendant_projects
|
||||
# Assign an issue of a project to a version of a child project
|
||||
Issue.find(4).update_attribute :fixed_version_id, 4
|
||||
|
||||
assert_no_difference "Project.count(:all, :conditions => 'status = #{Project::STATUS_ARCHIVED}')" do
|
||||
assert_equal false, @ecookbook.archive
|
||||
end
|
||||
@ecookbook.reload
|
||||
assert @ecookbook.active?
|
||||
end
|
||||
|
||||
def test_unarchive
|
||||
user = @ecookbook.members.first.user
|
||||
@ecookbook.archive
|
||||
@@ -206,6 +214,38 @@ class ProjectTest < ActiveSupport::TestCase
|
||||
assert_equal 4, parent.children.size
|
||||
assert_equal parent.children.sort_by(&:name), parent.children
|
||||
end
|
||||
|
||||
|
||||
def test_set_parent_should_update_issue_fixed_version_associations_when_a_fixed_version_is_moved_out_of_the_hierarchy
|
||||
# Parent issue with a hierarchy project's fixed version
|
||||
parent_issue = Issue.find(1)
|
||||
parent_issue.update_attribute(:fixed_version_id, 4)
|
||||
parent_issue.reload
|
||||
assert_equal 4, parent_issue.fixed_version_id
|
||||
|
||||
# Should keep fixed versions for the issues
|
||||
issue_with_local_fixed_version = Issue.find(5)
|
||||
issue_with_local_fixed_version.update_attribute(:fixed_version_id, 4)
|
||||
issue_with_local_fixed_version.reload
|
||||
assert_equal 4, issue_with_local_fixed_version.fixed_version_id
|
||||
|
||||
# Local issue with hierarchy fixed_version
|
||||
issue_with_hierarchy_fixed_version = Issue.find(13)
|
||||
issue_with_hierarchy_fixed_version.update_attribute(:fixed_version_id, 6)
|
||||
issue_with_hierarchy_fixed_version.reload
|
||||
assert_equal 6, issue_with_hierarchy_fixed_version.fixed_version_id
|
||||
|
||||
# Move project out of the issue's hierarchy
|
||||
moved_project = Project.find(3)
|
||||
moved_project.set_parent!(Project.find(2))
|
||||
parent_issue.reload
|
||||
issue_with_local_fixed_version.reload
|
||||
issue_with_hierarchy_fixed_version.reload
|
||||
|
||||
assert_equal 4, issue_with_local_fixed_version.fixed_version_id, "Fixed version was not keep on an issue local to the moved project"
|
||||
assert_equal nil, issue_with_hierarchy_fixed_version.fixed_version_id, "Fixed version is still set after moving the Project out of the hierarchy where the version is defined in"
|
||||
assert_equal nil, parent_issue.fixed_version_id, "Fixed version is still set after moving the Version out of the hierarchy for the issue."
|
||||
end
|
||||
|
||||
def test_parent
|
||||
p = Project.find(6).parent
|
||||
@@ -277,13 +317,61 @@ class ProjectTest < ActiveSupport::TestCase
|
||||
|
||||
assert_equal [1,2], parent.rolled_up_trackers.collect(&:id)
|
||||
end
|
||||
|
||||
def test_shared_versions
|
||||
parent = Project.find(1)
|
||||
child = parent.children.find(3)
|
||||
private_child = parent.children.find(5)
|
||||
|
||||
assert_equal [1,2,3], parent.version_ids.sort
|
||||
assert_equal [4], child.version_ids
|
||||
assert_equal [6], private_child.version_ids
|
||||
assert_equal [7], Version.find_all_by_sharing('system').collect(&:id)
|
||||
|
||||
assert_equal 6, parent.shared_versions.size
|
||||
parent.shared_versions.each do |version|
|
||||
assert_kind_of Version, version
|
||||
end
|
||||
|
||||
assert_equal [1,2,3,4,6,7], parent.shared_versions.collect(&:id).sort
|
||||
end
|
||||
|
||||
def test_shared_versions_should_ignore_archived_subprojects
|
||||
parent = Project.find(1)
|
||||
child = parent.children.find(3)
|
||||
child.archive
|
||||
parent.reload
|
||||
|
||||
assert_equal [1,2,3], parent.version_ids.sort
|
||||
assert_equal [4], child.version_ids
|
||||
assert !parent.shared_versions.collect(&:id).include?(4)
|
||||
end
|
||||
|
||||
def test_shared_versions_visible_to_user
|
||||
user = User.find(3)
|
||||
parent = Project.find(1)
|
||||
child = parent.children.find(5)
|
||||
|
||||
assert_equal [1,2,3], parent.version_ids.sort
|
||||
assert_equal [6], child.version_ids
|
||||
|
||||
versions = parent.shared_versions.visible(user)
|
||||
|
||||
assert_equal 4, versions.size
|
||||
versions.each do |version|
|
||||
assert_kind_of Version, version
|
||||
end
|
||||
|
||||
assert !versions.collect(&:id).include?(6)
|
||||
end
|
||||
|
||||
|
||||
def test_next_identifier
|
||||
ProjectCustomField.delete_all
|
||||
Project.create!(:name => 'last', :identifier => 'p2008040')
|
||||
assert_equal 'p2008041', Project.next_identifier
|
||||
end
|
||||
|
||||
|
||||
def test_next_identifier_first_project
|
||||
Project.delete_all
|
||||
assert_nil Project.next_identifier
|
||||
@@ -429,13 +517,15 @@ class ProjectTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
should "change the new issues to use the copied version" do
|
||||
assigned_version = Version.generate!(:name => "Assigned Issues")
|
||||
User.current = User.find(1)
|
||||
assigned_version = Version.generate!(:name => "Assigned Issues", :status => 'open')
|
||||
@source_project.versions << assigned_version
|
||||
assert_equal 1, @source_project.versions.size
|
||||
@source_project.issues << Issue.generate!(:fixed_version_id => assigned_version.id,
|
||||
:subject => "change the new issues to use the copied version",
|
||||
:tracker_id => 1,
|
||||
:project_id => @source_project.id)
|
||||
assert_equal 3, @source_project.versions.size
|
||||
Issue.generate_for_project!(@source_project,
|
||||
:fixed_version_id => assigned_version.id,
|
||||
:subject => "change the new issues to use the copied version",
|
||||
:tracker_id => 1,
|
||||
:project_id => @source_project.id)
|
||||
|
||||
assert @project.copy(@source_project)
|
||||
@project.reload
|
||||
|
||||
Reference in new issue
Block a user