Adds a setting to allow subtasks to belong to other projects (#5487).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10587 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2012-10-10 17:38:17 +00:00
parent b0013d9f68
commit 83bcc1f043
12 changed files with 128 additions and 9 deletions
+9 -1
View File
@@ -49,7 +49,15 @@ class IssueNestedSetTest < ActiveSupport::TestCase
assert_equal [parent.id, parent.id, 2, 3], [child.root_id, child.parent_id, child.lft, child.rgt]
end
def test_creating_a_child_in_different_project_should_not_validate
def test_creating_a_child_in_a_subproject_should_validate
issue = create_issue!
child = Issue.new(:project_id => 3, :tracker_id => 2, :author_id => 1,
:subject => 'child', :parent_issue_id => issue.id)
assert_save child
assert_equal issue, child.reload.parent
end
def test_creating_a_child_in_an_invalid_project_should_not_validate
issue = create_issue!
child = Issue.new(:project_id => 2, :tracker_id => 1, :author_id => 1,
:subject => 'child', :parent_issue_id => issue.id)
+60
View File
@@ -906,6 +906,24 @@ class IssueTest < ActiveSupport::TestCase
assert_equal 7, issue.fixed_version_id
end
def test_move_to_another_project_should_keep_parent_if_valid
issue = Issue.find(1)
issue.update_attribute(:parent_issue_id, 2)
issue.project = Project.find(3)
assert issue.save
issue.reload
assert_equal 2, issue.parent_id
end
def test_move_to_another_project_should_clear_parent_if_not_valid
issue = Issue.find(1)
issue.update_attribute(:parent_issue_id, 2)
issue.project = Project.find(2)
assert issue.save
issue.reload
assert_nil issue.parent_id
end
def test_move_to_another_project_with_disabled_tracker
issue = Issue.find(1)
target = Project.find(2)
@@ -996,6 +1014,48 @@ class IssueTest < ActiveSupport::TestCase
end
end
def test_valid_parent_project
issue = Issue.find(1)
issue_in_same_project = Issue.find(2)
issue_in_child_project = Issue.find(5)
issue_in_grandchild_project = Issue.generate!(:project_id => 6, :tracker_id => 1)
issue_in_other_child_project = Issue.find(6)
issue_in_different_tree = Issue.find(4)
with_settings :cross_project_subtasks => '' do
assert_equal true, issue.valid_parent_project?(issue_in_same_project)
assert_equal false, issue.valid_parent_project?(issue_in_child_project)
assert_equal false, issue.valid_parent_project?(issue_in_grandchild_project)
assert_equal false, issue.valid_parent_project?(issue_in_different_tree)
end
with_settings :cross_project_subtasks => 'system' do
assert_equal true, issue.valid_parent_project?(issue_in_same_project)
assert_equal true, issue.valid_parent_project?(issue_in_child_project)
assert_equal true, issue.valid_parent_project?(issue_in_different_tree)
end
with_settings :cross_project_subtasks => 'tree' do
assert_equal true, issue.valid_parent_project?(issue_in_same_project)
assert_equal true, issue.valid_parent_project?(issue_in_child_project)
assert_equal true, issue.valid_parent_project?(issue_in_grandchild_project)
assert_equal false, issue.valid_parent_project?(issue_in_different_tree)
assert_equal true, issue_in_child_project.valid_parent_project?(issue_in_same_project)
assert_equal true, issue_in_child_project.valid_parent_project?(issue_in_other_child_project)
end
with_settings :cross_project_subtasks => 'descendants' do
assert_equal true, issue.valid_parent_project?(issue_in_same_project)
assert_equal false, issue.valid_parent_project?(issue_in_child_project)
assert_equal false, issue.valid_parent_project?(issue_in_grandchild_project)
assert_equal false, issue.valid_parent_project?(issue_in_different_tree)
assert_equal true, issue_in_child_project.valid_parent_project?(issue)
assert_equal false, issue_in_child_project.valid_parent_project?(issue_in_other_child_project)
end
end
def test_recipients_should_include_previous_assignee
user = User.find(3)
user.members.update_all ["mail_notification = ?", false]