Skip to content

Commit

Permalink
Don't error when checking user roles on a project
Browse files Browse the repository at this point in the history
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 called on a project.
  • Loading branch information
eduardoj committed Dec 13, 2024
1 parent 3c92fcd commit e3d60a9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/api/app/controllers/webui/request_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,11 @@ 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)).distinct
maintainer_role = Role.find_by_title('maintainer')
projects.any? { |project| Project.find_by_name(project).user_has_role?(User.possibly_nobody, maintainer_role) }
user = User.possibly_nobody

projects.any? { |project| project.user_has_role?(user, maintainer_role) }
end

def new_state
Expand Down

0 comments on commit e3d60a9

Please sign in to comment.