Project

General

Profile

Defect #32860 » 32860-v2.patch

Go MAEDA, 2020-07-04 03:30

View differences:

app/helpers/versions_helper.rb
31 31
    options = {:fixed_version_id => version, :set_filter => 1}.merge(options)
32 32
    project =
33 33
      case version.sharing
34
      when 'hierarchy', 'tree'
35
        if version.project && version.project.root.visible?
34
      when 'tree'
35
        if version.project && version.project.root.visible? && User.current.allowed_to?(:view_issues, version.project.root)
36 36
          version.project.root
37 37
        else
38
          version.project
38
          nil
39 39
        end
40 40
      when 'system'
41 41
        nil
test/helpers/version_helper_test.rb
42 42
  def test_version_filtered_issues_path_sharing_hierarchy
43 43
    version = Version.new(:name => 'test', :sharing => 'hierarchy')
44 44
    version.project = Project.find(5)
45
    assert_match '/projects/ecookbook/issues?', version_filtered_issues_path(version)
45
    assert_match '/projects/private-child/issues?', version_filtered_issues_path(version)
46 46
  end
47 47

  
48 48
  def test_version_filtered_issues_path_sharing_tree
......
51 51
    assert_match '/projects/ecookbook/issues?', version_filtered_issues_path(version)
52 52
  end
53 53

  
54
  def test_version_filtered_issues_path_sharing_tree_without_permission_to_root_project
55
    EnabledModule.where("name = 'issue_tracking' AND project_id = 1").delete_all
56
    version = Version.new(:name => 'test', :sharing => 'tree')
57
    version.project = Project.find(5)
58
    assert_no_match '/projects/ecookbook/issues?', version_filtered_issues_path(version)
59
    assert_match '/issues?', version_filtered_issues_path(version)
60
  end
61

  
54 62
  def test_version_filtered_issues_path_sharing_system
55 63
    version = Version.new(:name => 'test', :sharing => 'system')
56 64
    version.project = Project.find(5)
(4-4/4)