From da4303a96113a34f01b606adf676e9515c2b33d0 Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Tue, 27 Jul 2021 04:55:08 +0000 Subject: [PATCH] Locked users should not be displayed in the members box of the project overview page (#35606). Patch by Mizuki ISHIKAWA. git-svn-id: http://svn.redmine.org/redmine/trunk@21090 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/project.rb | 2 +- test/unit/project_test.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/models/project.rb b/app/models/project.rb index 0afb4bdda..4d5e3c051 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -550,7 +550,7 @@ class Project < ActiveRecord::Base # Returns a hash of project users/groups grouped by role def principals_by_role - memberships.includes(:principal, :roles).inject({}) do |h, m| + memberships.active.includes(:principal, :roles).inject({}) do |h, m| m.roles.each do |r| h[r] ||= [] h[r] << m.principal diff --git a/test/unit/project_test.rb b/test/unit/project_test.rb index 2c23feb83..0862f9d9c 100644 --- a/test/unit/project_test.rb +++ b/test/unit/project_test.rb @@ -475,6 +475,16 @@ class ProjectTest < ActiveSupport::TestCase assert principals_by_role[role].include?(group) end + def test_principals_by_role_should_only_return_active_users + #group = Group.find(10) + #Member.create!(:principal => group, :project_id => 1, :role_ids => [1]) + + principals_by_role = Project.find(1).principals_by_role + locked_user = User.find(5) + assert Project.find(1).memberships.map(&:principal).include?(locked_user) + assert_not principals_by_role.values.flatten.include?(locked_user) + end + def test_rolled_up_trackers parent = Project.find(1) parent.trackers = Tracker.find([1, 2]) -- 2.39.5