From 1bf1feaf523ac94720dd57ac7689a0ef7efcad8a Mon Sep 17 00:00:00 2001 From: Eduardo Navarro Date: Wed, 11 Dec 2024 14:13:41 +0100 Subject: [PATCH] Don't error when checking user roles on a project Substitute the call to the overwritten `Project.find_by_name` finder method with plain ActiveRecord finder methods. Make sure the `user_has_role?` method is always call on a project. --- src/api/app/controllers/webui/request_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/app/controllers/webui/request_controller.rb b/src/api/app/controllers/webui/request_controller.rb index 626c850628d..7bec5e71102 100644 --- a/src/api/app/controllers/webui/request_controller.rb +++ b/src/api/app/controllers/webui/request_controller.rb @@ -352,9 +352,9 @@ def addreview_opts end def any_project_maintained_by_current_user? - projects = @actions.select(:target_project).distinct.pluck(:target_project) + projects = Project.where(name: @actions.select(:target_project)) maintainer_role = Role.find_by_title('maintainer') - projects.any? { |project| Project.find_by_name(project).user_has_role?(User.possibly_nobody, maintainer_role) } + projects.any? { |project| project.user_has_role?(User.possibly_nobody, maintainer_role) } end def new_state