diff options
author | Go MAEDA <maeda@farend.jp> | 2021-01-01 00:59:07 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2021-01-01 00:59:07 +0000 |
commit | 3f3514d8b1a6c7db39c7b0e180598437a210fac0 (patch) | |
tree | 39b2f8498584ffa36ff07baff92a38e6bf5bdc35 /test/unit/issue_test.rb | |
parent | 2ee2b349879a0816fc49700fade0be1750a6fa87 (diff) | |
download | redmine-3f3514d8b1a6c7db39c7b0e180598437a210fac0.tar.gz redmine-3f3514d8b1a6c7db39c7b0e180598437a210fac0.zip |
Show only valid projects on issue form when the issue is a subtask (#33419).
Patch by Marius BALTEANU.
git-svn-id: http://svn.redmine.org/redmine/trunk@20701 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/issue_test.rb')
-rw-r--r-- | test/unit/issue_test.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb index 95812376a..4a7c663b5 100644 --- a/test/unit/issue_test.rb +++ b/test/unit/issue_test.rb @@ -1708,6 +1708,17 @@ class IssueTest < ActiveSupport::TestCase assert_not_include project, Issue.allowed_target_projects(User.find(1)) end + def test_allowed_target_projects_for_subtask_should_not_include_invalid_projects + User.current = User.find(1) + issue = Issue.find(1) + issue.parent_id = 3 + + with_settings :cross_project_subtasks => 'tree' do + # Should include only the project tree + assert_equal [1, 3, 5], issue.allowed_target_projects_for_subtask.ids.sort + end + end + def test_allowed_target_trackers_with_one_role_allowed_on_all_trackers user = User.generate! role = Role.generate! @@ -3343,4 +3354,27 @@ class IssueTest < ActiveSupport::TestCase assert !child.reopenable? assert_equal l(:notice_issue_not_reopenable_by_closed_parent_issue), child.transition_warning end + + def test_filter_projects_scope + Issue.send(:public, :filter_projects_scope) + # Project eCookbook + issue = Issue.find(1) + + assert_equal Project, issue.filter_projects_scope + assert_equal Project, issue.filter_projects_scope('system') + + # Project Onlinestore (id 2) is not part of the tree + assert_equal [1, 3, 4, 5, 6], Issue.find(5).filter_projects_scope('tree').ids.sort + + # Project "Private child of eCookbook" + issue2 = Issue.find(9) + + # Projects "eCookbook Subproject 1" (id 3) and "eCookbook Subproject 1" (id 4) are not part of hierarchy + assert_equal [1, 5, 6], issue2.filter_projects_scope('hierarchy').ids.sort + + # Project "Child of private child" is descendant of "Private child of eCookbook" + assert_equal [5, 6], issue2.filter_projects_scope('descendants').ids.sort + + assert_equal [5], issue2.filter_projects_scope('').ids.sort + end end |