From 4e4985d75c83de5b46c5d2323844e29057d70b5a Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Thu, 18 Mar 2021 08:56:40 +0000 Subject: [PATCH] Merged r20819 from trunk to 4.1-stable (#33360). git-svn-id: http://svn.redmine.org/redmine/branches/4.1-stable@20820 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/issues_helper.rb | 3 ++- test/helpers/issues_helper_test.rb | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 9ab139552..30a2470e9 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -577,6 +577,7 @@ module IssuesHelper end # Find the name of an associated record stored in the field attribute + # For project, return the associated record only if is visible for the current User def find_name_by_reflection(field, id) return nil if id.blank? @detail_value_name_by_reflection ||= Hash.new do |hash, key| @@ -584,7 +585,7 @@ module IssuesHelper name = nil if association record = association.klass.find_by_id(key.last) - if record + if (record && !record.is_a?(Project)) || (record.is_a?(Project) && record.visible?) name = record.name.force_encoding('UTF-8') end end diff --git a/test/helpers/issues_helper_test.rb b/test/helpers/issues_helper_test.rb index afa33a631..89c9de0ef 100644 --- a/test/helpers/issues_helper_test.rb +++ b/test/helpers/issues_helper_test.rb @@ -143,12 +143,20 @@ class IssuesHelperTest < Redmine::HelperTest end test 'show_detail should show old and new values with a project attribute' do + User.current = User.find(2) detail = JournalDetail.new(:property => 'attr', :prop_key => 'project_id', :old_value => 1, :value => 2) assert_match 'eCookbook', show_detail(detail, true) assert_match 'OnlineStore', show_detail(detail, true) end + test 'show_detail with a project attribute should show project ID if project is not visible' do + detail = JournalDetail.new(:property => 'attr', :prop_key => 'project_id', + :old_value => 1, :value => 2) + assert_match 'eCookbook', show_detail(detail, true) + assert_match '2', show_detail(detail, true) + end + test 'show_detail should show old and new values with a issue status attribute' do detail = JournalDetail.new(:property => 'attr', :prop_key => 'status_id', :old_value => 1, :value => 2) -- 2.39.5