]> source.dussan.org Git - redmine.git/commitdiff
Invalid links to versions with sharing in project tree (#32860).
authorGo MAEDA <maeda@farend.jp>
Sun, 18 Oct 2020 02:28:27 +0000 (02:28 +0000)
committerGo MAEDA <maeda@farend.jp>
Sun, 18 Oct 2020 02:28:27 +0000 (02:28 +0000)
Patch by Alexander Meindl.

git-svn-id: http://svn.redmine.org/redmine/trunk@20149 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/versions_helper.rb
test/helpers/version_helper_test.rb

index 219ced3d31a499fcfa64c8b13fecb72cf6acbe99..36b1b511d7223f37b64f604f1cd694cc68b5d8e0 100644 (file)
@@ -31,11 +31,11 @@ module VersionsHelper
     options = {:fixed_version_id => version, :set_filter => 1}.merge(options)
     project =
       case version.sharing
-      when 'hierarchy', 'tree'
-        if version.project && version.project.root.visible?
+      when 'tree'
+        if version.project && version.project.root.visible? && User.current.allowed_to?(:view_issues, version.project.root)
           version.project.root
         else
-          version.project
+          nil
         end
       when 'system'
         nil
index a0a16d341292c8a837b4faab415ec79f7afa633f..0eb895e4775ffeb604510963d161ac41538d2d33 100644 (file)
@@ -42,7 +42,7 @@ class VersionsHelperTest < Redmine::HelperTest
   def test_version_filtered_issues_path_sharing_hierarchy
     version = Version.new(:name => 'test', :sharing => 'hierarchy')
     version.project = Project.find(5)
-    assert_match '/projects/ecookbook/issues?', version_filtered_issues_path(version)
+    assert_match '/projects/private-child/issues?', version_filtered_issues_path(version)
   end
 
   def test_version_filtered_issues_path_sharing_tree
@@ -51,6 +51,14 @@ class VersionsHelperTest < Redmine::HelperTest
     assert_match '/projects/ecookbook/issues?', version_filtered_issues_path(version)
   end
 
+  def test_version_filtered_issues_path_sharing_tree_without_permission_to_root_project
+    EnabledModule.where("name = 'issue_tracking' AND project_id = 1").delete_all
+    version = Version.new(:name => 'test', :sharing => 'tree')
+    version.project = Project.find(5)
+    assert_no_match '/projects/ecookbook/issues?', version_filtered_issues_path(version)
+    assert_match '/issues?', version_filtered_issues_path(version)
+  end
+
   def test_version_filtered_issues_path_sharing_system
     version = Version.new(:name => 'test', :sharing => 'system')
     version.project = Project.find(5)