diff options
author | Go MAEDA <maeda@farend.jp> | 2021-03-18 08:57:39 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2021-03-18 08:57:39 +0000 |
commit | 4862a188139c4c9eeca8c8c6308e3ce20d10b508 (patch) | |
tree | 7b263175d5ab26118b1a5cf6089da52256e98320 | |
parent | e3abac586a6b2eb99e858eca757f056728b67703 (diff) | |
download | redmine-4862a188139c4c9eeca8c8c6308e3ce20d10b508.tar.gz redmine-4862a188139c4c9eeca8c8c6308e3ce20d10b508.zip |
Merged r20819 from trunk to 4.0-stable (#33360).
git-svn-id: http://svn.redmine.org/redmine/branches/4.0-stable@20821 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | app/helpers/issues_helper.rb | 3 | ||||
-rw-r--r-- | test/helpers/issues_helper_test.rb | 8 |
2 files changed, 10 insertions, 1 deletions
diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index aee8444f5..11ccb58b5 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -501,6 +501,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) unless id.present? return nil @@ -510,7 +511,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 6908d5128..be16e1d94 100644 --- a/test/helpers/issues_helper_test.rb +++ b/test/helpers/issues_helper_test.rb @@ -141,12 +141,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) |